Received: by 10.223.176.5 with SMTP id f5csp1027378wra; Fri, 2 Feb 2018 09:57:41 -0800 (PST) X-Google-Smtp-Source: AH8x224XQWeVCPYMujaTvTNatrXKUjJXu/jr0Fg27WWkz0lvys1FkbXmlOyWW2v7QatVapmgFLVL X-Received: by 10.98.89.198 with SMTP id k67mr41008218pfj.110.1517594261400; Fri, 02 Feb 2018 09:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594261; cv=none; d=google.com; s=arc-20160816; b=0UW35dBF2TAntN+bcIUp/VNAqaeAHj6n+s8vzEt0MYjrwqV7hVoAGnzs6oy8FjxdmB PByMPvQBplstz/x0otB8zc4xWf8YloyLuB8ZaHYLRadL1HBxCn2zUN4BY2wa3ZP1i1qv SMxyVGpJTiPJyPr09J56Dqx7WqvYX8ohQ3f9jrZyBhdWzzm3D5frSiq1RtFhYCBmQm0P vDF7WRRFwWCP/KZL23IDyWAtyBH5LyCjhWqLGed1QqMP7KBbmvo97Htdpt79Tyig+75Q CJeRANGd26dxNA1mItt/OLSYPfeR/T1fWYgTQnyAzqgbz9f3UV2U+TM7MgiyY4khyAHe bLjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=o7bbXmV2+BFr00KYt+Al8ZulHw2PnKowK2jpeq9gVIs=; b=M0T+wUUA9EEgIaHNJYCpUnvITbk+QelLhPZ0oFLEiIl0F+iSd/vEHyvd93Idi3nK+k 91kKg1MBTw+XS1iUapokXwaMgscHTmlYhoW6rbfOA/IY5rpMH5TL9mXoxDeezt20kwMP 4oqVaOCtkq/hLevH71t/IPQvBwEhTtllJ45AduizWxTSdNz4KjQiXbiKuRLi1Vh6Q1yj Zurt5+2V7meQNnBxN5Lu6o8jy65Dg0Bwtorr/jzx1q6jBLbxUihtXr8ZQOCSV3tXwWIC wc4PbrIFA9F35M+OQw4cwexZkbh81eoky3Q0enj4LI9JnHVNuUkp9pzORFKdiwKG6Faf ImMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g189si257458pfc.386.2018.02.02.09.57.26; Fri, 02 Feb 2018 09:57:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753825AbeBBR43 (ORCPT + 99 others); Fri, 2 Feb 2018 12:56:29 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38568 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753376AbeBBRLO (ORCPT ); Fri, 2 Feb 2018 12:11:14 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2874EEB3; Fri, 2 Feb 2018 17:11:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Chao Yu , Sasha Levin Subject: [PATCH 4.14 092/156] quota: propagate error from __dquot_initialize Date: Fri, 2 Feb 2018 17:57:53 +0100 Message-Id: <20180202140844.405332383@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chao Yu [ Upstream commit 1a6152d36dee08da2be2a3030dceb45ef680460a ] In commit 6184fc0b8dd7 ("quota: Propagate error from ->acquire_dquot()"), we have propagated error from __dquot_initialize to caller, but we forgot to handle such error in add_dquot_ref(), so, currently, during quota accounting information initialization flow, if we failed for some of inodes, we just ignore such error, and do account for others, which is not a good implementation. In this patch, we choose to let user be aware of such error, so after turning on quota successfully, we can make sure all inodes disk usage can be accounted, which will be more reasonable. Suggested-by: Jan Kara Signed-off-by: Chao Yu Signed-off-by: Jan Kara Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/quota/dquot.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -934,12 +934,13 @@ static int dqinit_needed(struct inode *i } /* This routine is guarded by s_umount semaphore */ -static void add_dquot_ref(struct super_block *sb, int type) +static int add_dquot_ref(struct super_block *sb, int type) { struct inode *inode, *old_inode = NULL; #ifdef CONFIG_QUOTA_DEBUG int reserved = 0; #endif + int err = 0; spin_lock(&sb->s_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { @@ -959,7 +960,11 @@ static void add_dquot_ref(struct super_b reserved = 1; #endif iput(old_inode); - __dquot_initialize(inode, type); + err = __dquot_initialize(inode, type); + if (err) { + iput(inode); + goto out; + } /* * We hold a reference to 'inode' so it couldn't have been @@ -974,7 +979,7 @@ static void add_dquot_ref(struct super_b } spin_unlock(&sb->s_inode_list_lock); iput(old_inode); - +out: #ifdef CONFIG_QUOTA_DEBUG if (reserved) { quota_error(sb, "Writes happened before quota was turned on " @@ -982,6 +987,7 @@ static void add_dquot_ref(struct super_b "Please run quotacheck(8)"); } #endif + return err; } /* @@ -2372,10 +2378,11 @@ static int vfs_load_quota_inode(struct i dqopt->flags |= dquot_state_flag(flags, type); spin_unlock(&dq_state_lock); - add_dquot_ref(sb, type); - - return 0; + error = add_dquot_ref(sb, type); + if (error) + dquot_disable(sb, type, flags); + return error; out_file_init: dqopt->files[type] = NULL; iput(inode);