Return-Path: Received: from mail-sn1nam01on0105.outbound.protection.outlook.com ([104.47.32.105]:55328 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932432AbeAXEP6 (ORCPT ); Tue, 23 Jan 2018 23:15:58 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Chao Yu , Jan Kara , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 064/100] quota: propagate error from __dquot_initialize Date: Wed, 24 Jan 2018 04:14:57 +0000 Message-ID: <20180124041414.32065-64-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: 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 --- fs/quota/dquot.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 9f78b5015f2e..8406be97a518 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -934,12 +934,13 @@ static int dqinit_needed(struct inode *inode, int typ= e) } =20 /* 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 =3D NULL; #ifdef CONFIG_QUOTA_DEBUG int reserved =3D 0; #endif + int err =3D 0; =20 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_block *sb, int = type) reserved =3D 1; #endif iput(old_inode); - __dquot_initialize(inode, type); + err =3D __dquot_initialize(inode, type); + if (err) { + iput(inode); + goto out; + } =20 /* * We hold a reference to 'inode' so it couldn't have been @@ -974,7 +979,7 @@ static void add_dquot_ref(struct super_block *sb, int t= ype) } 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_block *sb, int t= ype) "Please run quotacheck(8)"); } #endif + return err; } =20 /* @@ -2372,10 +2378,11 @@ static int vfs_load_quota_inode(struct inode *inode= , int type, int format_id, dqopt->flags |=3D dquot_state_flag(flags, type); spin_unlock(&dq_state_lock); =20 - add_dquot_ref(sb, type); - - return 0; + error =3D add_dquot_ref(sb, type); + if (error) + dquot_disable(sb, type, flags); =20 + return error; out_file_init: dqopt->files[type] =3D NULL; iput(inode); --=20 2.11.0