linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] quota: propagate error from __dquot_initialize
@ 2017-11-23 15:21 Chao Yu
  2017-11-27 15:56 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2017-11-23 15:21 UTC (permalink / raw)
  To: jack; +Cc: linux-kernel, linux-fsdevel, chao, Chao Yu

From: Chao Yu <yuchao0@huawei.com>

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 <jack@suse.cz>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
v2:
- fix incorrect error path handling in vfs_load_quota_inode.
 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 8381db9db6d9..7ea02fc315cd 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -933,12 +933,13 @@ static int dqinit_needed(struct inode *inode, int type)
 }
 
 /* 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) {
@@ -958,7 +959,11 @@ static void add_dquot_ref(struct super_block *sb, int type)
 			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
@@ -973,7 +978,7 @@ static void add_dquot_ref(struct super_block *sb, int type)
 	}
 	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 "
@@ -981,6 +986,7 @@ static void add_dquot_ref(struct super_block *sb, int type)
 			"Please run quotacheck(8)");
 	}
 #endif
+	return err;
 }
 
 /*
@@ -2364,10 +2370,11 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
 	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, dqopt->flags);
 
+	return error;
 out_file_init:
 	dqopt->files[type] = NULL;
 	iput(inode);
-- 
2.14.1.145.gb3622a4ee

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] quota: propagate error from __dquot_initialize
  2017-11-23 15:21 [PATCH v2] quota: propagate error from __dquot_initialize Chao Yu
@ 2017-11-27 15:56 ` Jan Kara
  2017-11-28 14:58   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2017-11-27 15:56 UTC (permalink / raw)
  To: Chao Yu; +Cc: jack, linux-kernel, linux-fsdevel, Chao Yu

On Thu 23-11-17 23:21:01, Chao Yu wrote:
> @@ -2364,10 +2370,11 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
>  	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, dqopt->flags);

Why dqopt->flags? If anything these flags are shifted by user/group/project
shift and combined together for all the types. You need to just pass
'flags' here. Other than that the patch looks good.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] quota: propagate error from __dquot_initialize
  2017-11-27 15:56 ` Jan Kara
@ 2017-11-28 14:58   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2017-11-28 14:58 UTC (permalink / raw)
  To: Jan Kara; +Cc: jack, linux-kernel, linux-fsdevel, Chao Yu

On 2017/11/27 23:56, Jan Kara wrote:
> On Thu 23-11-17 23:21:01, Chao Yu wrote:
>> @@ -2364,10 +2370,11 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
>>  	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, dqopt->flags);
> 
> Why dqopt->flags? If anything these flags are shifted by user/group/project

Oh, correct, user/group/project type quota flags are shifted and merged into
dqopt->flags.... just notice that, sorry.

Let me update the patch. :)

Thanks,

> shift and combined together for all the types. You need to just pass
> 'flags' here. Other than that the patch looks good.
> 
> 								Honza
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-28 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 15:21 [PATCH v2] quota: propagate error from __dquot_initialize Chao Yu
2017-11-27 15:56 ` Jan Kara
2017-11-28 14:58   ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).