All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled
@ 2018-07-24 12:17 Sheng Yong
  2018-07-24 12:17 ` [PATCH 2/3] f2fs: quota: decrease the lock granularity of statfs_project Sheng Yong
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sheng Yong @ 2018-07-24 12:17 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

If quota feature is enabled, quota is on by default. However, if
CONFIG_QUOTA is not built in kernel, dquot entries will not get updated,
which leads to quota inconsistency.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fs/f2fs/super.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 0a8e12662174..796a2d756572 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -346,12 +346,6 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi)
 			"QUOTA feature is enabled, so ignore jquota_fmt");
 		F2FS_OPTION(sbi).s_jquota_fmt = 0;
 	}
-	if (f2fs_sb_has_quota_ino(sbi->sb) && f2fs_readonly(sbi->sb)) {
-		f2fs_msg(sbi->sb, KERN_INFO,
-			 "Filesystem with quota feature cannot be mounted RDWR "
-			 "without CONFIG_QUOTA");
-		return -1;
-	}
 	return 0;
 }
 #endif
@@ -774,6 +768,13 @@ static int parse_options(struct super_block *sb, char *options)
 #ifdef CONFIG_QUOTA
 	if (f2fs_check_quota_options(sbi))
 		return -EINVAL;
+#else
+	if (f2fs_sb_has_quota_ino(sbi->sb) && !f2fs_readonly(sbi->sb)) {
+		f2fs_msg(sbi->sb, KERN_INFO,
+			 "Filesystem with quota feature cannot be mounted RDWR "
+			 "without CONFIG_QUOTA");
+		return -EINVAL;
+	}
 #endif
 
 	if (F2FS_IO_SIZE_BITS(sbi) && !test_opt(sbi, LFS)) {
-- 
2.17.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* [PATCH 2/3] f2fs: quota: decrease the lock granularity of statfs_project
  2018-07-24 12:17 [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled Sheng Yong
@ 2018-07-24 12:17 ` Sheng Yong
  2018-07-25 15:41   ` Chao Yu
  2018-07-24 12:17 ` [PATCH 3/3] f2fs: quota: fix incorrect error message and comments Sheng Yong
  2018-07-25 15:27 ` [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled Chao Yu
  2 siblings, 1 reply; 9+ messages in thread
From: Sheng Yong @ 2018-07-24 12:17 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

According to fs/quota/dquot.c, `dq_data_lock' protects mem_dqinfo
structures and modifications of dquot pointers in the inode, and
`dquot->dq_dqb_lock' protects data from dq_dqb.

We should use dquot->dq_dqb_lock in statfs_project instead of
dq_dat_lock.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fs/f2fs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 796a2d756572..4ed91ceab3ee 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1118,7 +1118,7 @@ static int f2fs_statfs_project(struct super_block *sb,
 	dquot = dqget(sb, qid);
 	if (IS_ERR(dquot))
 		return PTR_ERR(dquot);
-	spin_lock(&dq_data_lock);
+	spin_lock(&dquot->dq_dqb_lock);
 
 	limit = (dquot->dq_dqb.dqb_bsoftlimit ?
 		 dquot->dq_dqb.dqb_bsoftlimit :
@@ -1141,7 +1141,7 @@ static int f2fs_statfs_project(struct super_block *sb,
 			 (buf->f_files - dquot->dq_dqb.dqb_curinodes) : 0;
 	}
 
-	spin_unlock(&dq_data_lock);
+	spin_unlock(&dquot->dq_dqb_lock);
 	dqput(dquot);
 	return 0;
 }
-- 
2.17.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* [PATCH 3/3] f2fs: quota: fix incorrect error message and comments
  2018-07-24 12:17 [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled Sheng Yong
  2018-07-24 12:17 ` [PATCH 2/3] f2fs: quota: decrease the lock granularity of statfs_project Sheng Yong
@ 2018-07-24 12:17 ` Sheng Yong
  2018-07-25 15:44   ` Chao Yu
  2018-07-26 11:24   ` [PATCH v2] f2fs: quota: fix incorrect comments Sheng Yong
  2018-07-25 15:27 ` [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled Chao Yu
  2 siblings, 2 replies; 9+ messages in thread
From: Sheng Yong @ 2018-07-24 12:17 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fs/f2fs/checkpoint.c | 5 ++++-
 fs/f2fs/recovery.c   | 2 +-
 fs/f2fs/super.c      | 5 +----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 9c29526a7633..9a0222d9e28c 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -645,7 +645,10 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
 	/* Needed for iput() to work correctly and not trash data */
 	sbi->sb->s_flags |= SB_ACTIVE;
 
-	/* Turn on quotas so that they are updated correctly */
+	/*
+	 * Turn on quotas which were not enabled for read-only mounts if
+	 * filesystem has quota feature, so that they are updated correctly.
+	 */
 	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
 #endif
 
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 0d927ae26c48..e93162a2e6d8 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -628,7 +628,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 #endif
 
 	if (s_flags & SB_RDONLY) {
-		f2fs_msg(sbi->sb, KERN_INFO, "orphan cleanup on readonly fs");
+		f2fs_msg(sbi->sb, KERN_INFO, "fsync data recover on readonly fs");
 		sbi->sb->s_flags &= ~SB_RDONLY;
 	}
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 4ed91ceab3ee..3e24dde60f54 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2970,10 +2970,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 		goto free_root_inode;
 
 #ifdef CONFIG_QUOTA
-	/*
-	 * Turn on quotas which were not enabled for read-only mounts if
-	 * filesystem has quota feature, so that they are updated correctly.
-	 */
+	/* Enable quota usage during mount */
 	if (f2fs_sb_has_quota_ino(sb) && !f2fs_readonly(sb)) {
 		err = f2fs_enable_quotas(sb);
 		if (err) {
-- 
2.17.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled
  2018-07-24 12:17 [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled Sheng Yong
  2018-07-24 12:17 ` [PATCH 2/3] f2fs: quota: decrease the lock granularity of statfs_project Sheng Yong
  2018-07-24 12:17 ` [PATCH 3/3] f2fs: quota: fix incorrect error message and comments Sheng Yong
@ 2018-07-25 15:27 ` Chao Yu
  2 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2018-07-25 15:27 UTC (permalink / raw)
  To: Sheng Yong, jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

On 2018/7/24 20:17, Sheng Yong wrote:
> If quota feature is enabled, quota is on by default. However, if
> CONFIG_QUOTA is not built in kernel, dquot entries will not get updated,
> which leads to quota inconsistency.
> 
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH 2/3] f2fs: quota: decrease the lock granularity of statfs_project
  2018-07-24 12:17 ` [PATCH 2/3] f2fs: quota: decrease the lock granularity of statfs_project Sheng Yong
@ 2018-07-25 15:41   ` Chao Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2018-07-25 15:41 UTC (permalink / raw)
  To: Sheng Yong, jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

On 2018/7/24 20:17, Sheng Yong wrote:
> According to fs/quota/dquot.c, `dq_data_lock' protects mem_dqinfo
> structures and modifications of dquot pointers in the inode, and
> `dquot->dq_dqb_lock' protects data from dq_dqb.
> 
> We should use dquot->dq_dqb_lock in statfs_project instead of
> dq_dat_lock.
> 
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH 3/3] f2fs: quota: fix incorrect error message and comments
  2018-07-24 12:17 ` [PATCH 3/3] f2fs: quota: fix incorrect error message and comments Sheng Yong
@ 2018-07-25 15:44   ` Chao Yu
  2018-07-26  1:58     ` Sheng Yong
  2018-07-26 11:24   ` [PATCH v2] f2fs: quota: fix incorrect comments Sheng Yong
  1 sibling, 1 reply; 9+ messages in thread
From: Chao Yu @ 2018-07-25 15:44 UTC (permalink / raw)
  To: Sheng Yong, jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

On 2018/7/24 20:17, Sheng Yong wrote:
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
> ---
>  fs/f2fs/checkpoint.c | 5 ++++-
>  fs/f2fs/recovery.c   | 2 +-
>  fs/f2fs/super.c      | 5 +----
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> index 9c29526a7633..9a0222d9e28c 100644
> --- a/fs/f2fs/checkpoint.c
> +++ b/fs/f2fs/checkpoint.c
> @@ -645,7 +645,10 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
>  	/* Needed for iput() to work correctly and not trash data */
>  	sbi->sb->s_flags |= SB_ACTIVE;
>  
> -	/* Turn on quotas so that they are updated correctly */
> +	/*
> +	 * Turn on quotas which were not enabled for read-only mounts if
> +	 * filesystem has quota feature, so that they are updated correctly.
> +	 */
>  	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
>  #endif
>  
> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
> index 0d927ae26c48..e93162a2e6d8 100644
> --- a/fs/f2fs/recovery.c
> +++ b/fs/f2fs/recovery.c
> @@ -628,7 +628,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
>  #endif
>  
>  	if (s_flags & SB_RDONLY) {
> -		f2fs_msg(sbi->sb, KERN_INFO, "orphan cleanup on readonly fs");
> +		f2fs_msg(sbi->sb, KERN_INFO, "fsync data recover on readonly fs");

I remember Yunlei has fix this print info in another patch.

Thanks,

>  		sbi->sb->s_flags &= ~SB_RDONLY;
>  	}
>  
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 4ed91ceab3ee..3e24dde60f54 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2970,10 +2970,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>  		goto free_root_inode;
>  
>  #ifdef CONFIG_QUOTA
> -	/*
> -	 * Turn on quotas which were not enabled for read-only mounts if
> -	 * filesystem has quota feature, so that they are updated correctly.
> -	 */
> +	/* Enable quota usage during mount */
>  	if (f2fs_sb_has_quota_ino(sb) && !f2fs_readonly(sb)) {
>  		err = f2fs_enable_quotas(sb);
>  		if (err) {
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH 3/3] f2fs: quota: fix incorrect error message and comments
  2018-07-25 15:44   ` Chao Yu
@ 2018-07-26  1:58     ` Sheng Yong
  0 siblings, 0 replies; 9+ messages in thread
From: Sheng Yong @ 2018-07-26  1:58 UTC (permalink / raw)
  To: Chao Yu, jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel



On 2018/7/25 23:44, Chao Yu wrote:
> On 2018/7/24 20:17, Sheng Yong wrote:
>> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
>> ---
>>   fs/f2fs/checkpoint.c | 5 ++++-
>>   fs/f2fs/recovery.c   | 2 +-
>>   fs/f2fs/super.c      | 5 +----
>>   3 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
>> index 9c29526a7633..9a0222d9e28c 100644
>> --- a/fs/f2fs/checkpoint.c
>> +++ b/fs/f2fs/checkpoint.c
>> @@ -645,7 +645,10 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
>>   	/* Needed for iput() to work correctly and not trash data */
>>   	sbi->sb->s_flags |= SB_ACTIVE;
>>   
>> -	/* Turn on quotas so that they are updated correctly */
>> +	/*
>> +	 * Turn on quotas which were not enabled for read-only mounts if
>> +	 * filesystem has quota feature, so that they are updated correctly.
>> +	 */
>>   	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
>>   #endif
>>   
>> diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
>> index 0d927ae26c48..e93162a2e6d8 100644
>> --- a/fs/f2fs/recovery.c
>> +++ b/fs/f2fs/recovery.c
>> @@ -628,7 +628,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
>>   #endif
>>   
>>   	if (s_flags & SB_RDONLY) {
>> -		f2fs_msg(sbi->sb, KERN_INFO, "orphan cleanup on readonly fs");
>> +		f2fs_msg(sbi->sb, KERN_INFO, "fsync data recover on readonly fs");
> 
> I remember Yunlei has fix this print info in another patch.
> 

Hi, Chao,

I checked the list just now, yes, Yunlei has already submitted a patch to fix
the error message. Please ignore this :)

thanks

> Thanks,
> 
>>   		sbi->sb->s_flags &= ~SB_RDONLY;
>>   	}
>>   
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 4ed91ceab3ee..3e24dde60f54 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2970,10 +2970,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>>   		goto free_root_inode;
>>   
>>   #ifdef CONFIG_QUOTA
>> -	/*
>> -	 * Turn on quotas which were not enabled for read-only mounts if
>> -	 * filesystem has quota feature, so that they are updated correctly.
>> -	 */
>> +	/* Enable quota usage during mount */
>>   	if (f2fs_sb_has_quota_ino(sb) && !f2fs_readonly(sb)) {
>>   		err = f2fs_enable_quotas(sb);
>>   		if (err) {
>>
> 
> .
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* [PATCH v2] f2fs: quota: fix incorrect comments
  2018-07-24 12:17 ` [PATCH 3/3] f2fs: quota: fix incorrect error message and comments Sheng Yong
  2018-07-25 15:44   ` Chao Yu
@ 2018-07-26 11:24   ` Sheng Yong
  2018-07-26 11:33     ` Chao Yu
  1 sibling, 1 reply; 9+ messages in thread
From: Sheng Yong @ 2018-07-26 11:24 UTC (permalink / raw)
  To: jaegeuk, yuchao0; +Cc: miaoxie, linux-f2fs-devel

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fs/f2fs/checkpoint.c | 5 ++++-
 fs/f2fs/super.c      | 5 +----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 04841f32d4d9..581710760ba6 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -661,7 +661,10 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
 	/* Needed for iput() to work correctly and not trash data */
 	sbi->sb->s_flags |= SB_ACTIVE;
 
-	/* Turn on quotas so that they are updated correctly */
+	/*
+	 * Turn on quotas which were not enabled for read-only mounts if
+	 * filesystem has quota feature, so that they are updated correctly.
+	 */
 	quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
 #endif
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7187885da251..6ad0414ba303 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2968,10 +2968,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 		goto free_root_inode;
 
 #ifdef CONFIG_QUOTA
-	/*
-	 * Turn on quotas which were not enabled for read-only mounts if
-	 * filesystem has quota feature, so that they are updated correctly.
-	 */
+	/* Enable quota usage during mount */
 	if (f2fs_sb_has_quota_ino(sb) && !f2fs_readonly(sb)) {
 		err = f2fs_enable_quotas(sb);
 		if (err) {
-- 
2.17.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH v2] f2fs: quota: fix incorrect comments
  2018-07-26 11:24   ` [PATCH v2] f2fs: quota: fix incorrect comments Sheng Yong
@ 2018-07-26 11:33     ` Chao Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2018-07-26 11:33 UTC (permalink / raw)
  To: Sheng Yong, jaegeuk; +Cc: miaoxie, linux-f2fs-devel

On 2018/7/26 19:24, Sheng Yong wrote:
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

end of thread, other threads:[~2018-07-26 11:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24 12:17 [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled Sheng Yong
2018-07-24 12:17 ` [PATCH 2/3] f2fs: quota: decrease the lock granularity of statfs_project Sheng Yong
2018-07-25 15:41   ` Chao Yu
2018-07-24 12:17 ` [PATCH 3/3] f2fs: quota: fix incorrect error message and comments Sheng Yong
2018-07-25 15:44   ` Chao Yu
2018-07-26  1:58     ` Sheng Yong
2018-07-26 11:24   ` [PATCH v2] f2fs: quota: fix incorrect comments Sheng Yong
2018-07-26 11:33     ` Chao Yu
2018-07-25 15:27 ` [PATCH 1/3] f2fs: quota: do not mount as RDWR without QUOTA if quota feature enabled Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.