* [PATCH 1/4] quota: avoid missing put_quota_format when DQUOT_SUSPENDED is passed
2024-07-15 13:05 [PATCH 0/4] Fix and cleanups to quota Kemeng Shi
@ 2024-07-15 13:05 ` Kemeng Shi
2024-07-16 1:10 ` Joseph Qi
2024-07-15 13:05 ` [PATCH 2/4] quota: remove unneeded return value of register_quota_format Kemeng Shi
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Kemeng Shi @ 2024-07-15 13:05 UTC (permalink / raw)
To: jack
Cc: mark, jlbec, joseph.qi, hughd, akpm, ocfs2-devel, linux-kernel, linux-mm
Avoid missing put_quota_format when DQUOT_SUSPENDED is passed to
dquot_load_quota_sb.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/quota/dquot.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 627eb2f72ef3..23fcf9e9d6c5 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2408,7 +2408,7 @@ static int vfs_setup_quota_inode(struct inode *inode, int type)
int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,
unsigned int flags)
{
- struct quota_format_type *fmt = find_quota_format(format_id);
+ struct quota_format_type *fmt;
struct quota_info *dqopt = sb_dqopt(sb);
int error;
@@ -2418,6 +2418,7 @@ int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,
if (WARN_ON_ONCE(flags & DQUOT_SUSPENDED))
return -EINVAL;
+ fmt = find_quota_format(format_id);
if (!fmt)
return -ESRCH;
if (!sb->dq_op || !sb->s_qcop ||
--
2.30.0
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 1/4] quota: avoid missing put_quota_format when DQUOT_SUSPENDED is passed
2024-07-15 13:05 ` [PATCH 1/4] quota: avoid missing put_quota_format when DQUOT_SUSPENDED is passed Kemeng Shi
@ 2024-07-16 1:10 ` Joseph Qi
2024-07-17 13:09 ` Jan Kara
0 siblings, 1 reply; 9+ messages in thread
From: Joseph Qi @ 2024-07-16 1:10 UTC (permalink / raw)
To: Kemeng Shi, jack
Cc: mark, jlbec, hughd, akpm, ocfs2-devel, linux-kernel, linux-mm
On 7/15/24 9:05 PM, Kemeng Shi wrote:
> Avoid missing put_quota_format when DQUOT_SUSPENDED is passed to
> dquot_load_quota_sb.
>
It seems worth a 'Fixes' tag:
Fixes: d44c57663723 ("quota: Remove BUG_ON in dquot_load_quota_sb()")
Other looks good to me. So with the above addressed, feel free to add:
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
> fs/quota/dquot.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 627eb2f72ef3..23fcf9e9d6c5 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2408,7 +2408,7 @@ static int vfs_setup_quota_inode(struct inode *inode, int type)
> int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,
> unsigned int flags)
> {
> - struct quota_format_type *fmt = find_quota_format(format_id);
> + struct quota_format_type *fmt;
> struct quota_info *dqopt = sb_dqopt(sb);
> int error;
>
> @@ -2418,6 +2418,7 @@ int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,
> if (WARN_ON_ONCE(flags & DQUOT_SUSPENDED))
> return -EINVAL;
>
> + fmt = find_quota_format(format_id);
> if (!fmt)
> return -ESRCH;
> if (!sb->dq_op || !sb->s_qcop ||
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 1/4] quota: avoid missing put_quota_format when DQUOT_SUSPENDED is passed
2024-07-16 1:10 ` Joseph Qi
@ 2024-07-17 13:09 ` Jan Kara
0 siblings, 0 replies; 9+ messages in thread
From: Jan Kara @ 2024-07-17 13:09 UTC (permalink / raw)
To: Joseph Qi
Cc: Kemeng Shi, jack, mark, jlbec, hughd, akpm, ocfs2-devel,
linux-kernel, linux-mm
On Tue 16-07-24 09:10:18, Joseph Qi wrote:
>
>
> On 7/15/24 9:05 PM, Kemeng Shi wrote:
> > Avoid missing put_quota_format when DQUOT_SUSPENDED is passed to
> > dquot_load_quota_sb.
> >
>
> It seems worth a 'Fixes' tag:
> Fixes: d44c57663723 ("quota: Remove BUG_ON in dquot_load_quota_sb()")
>
> Other looks good to me. So with the above addressed, feel free to add:
> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Thanks for the patch and review. I'll add the tag on commit.
Honza
>
> > Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> > ---
> > fs/quota/dquot.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> > index 627eb2f72ef3..23fcf9e9d6c5 100644
> > --- a/fs/quota/dquot.c
> > +++ b/fs/quota/dquot.c
> > @@ -2408,7 +2408,7 @@ static int vfs_setup_quota_inode(struct inode *inode, int type)
> > int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,
> > unsigned int flags)
> > {
> > - struct quota_format_type *fmt = find_quota_format(format_id);
> > + struct quota_format_type *fmt;
> > struct quota_info *dqopt = sb_dqopt(sb);
> > int error;
> >
> > @@ -2418,6 +2418,7 @@ int dquot_load_quota_sb(struct super_block *sb, int type, int format_id,
> > if (WARN_ON_ONCE(flags & DQUOT_SUSPENDED))
> > return -EINVAL;
> >
> > + fmt = find_quota_format(format_id);
> > if (!fmt)
> > return -ESRCH;
> > if (!sb->dq_op || !sb->s_qcop ||
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/4] quota: remove unneeded return value of register_quota_format
2024-07-15 13:05 [PATCH 0/4] Fix and cleanups to quota Kemeng Shi
2024-07-15 13:05 ` [PATCH 1/4] quota: avoid missing put_quota_format when DQUOT_SUSPENDED is passed Kemeng Shi
@ 2024-07-15 13:05 ` Kemeng Shi
2024-07-16 1:19 ` Joseph Qi
2024-07-15 13:05 ` [PATCH 3/4] quota: remove redundant return at end of void function Kemeng Shi
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Kemeng Shi @ 2024-07-15 13:05 UTC (permalink / raw)
To: jack
Cc: mark, jlbec, joseph.qi, hughd, akpm, ocfs2-devel, linux-kernel, linux-mm
The register_quota_format always returns 0, simply remove unneeded return
value.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/ocfs2/super.c | 6 ++----
fs/quota/dquot.c | 3 +--
fs/quota/quota_v1.c | 3 ++-
fs/quota/quota_v2.c | 9 +++------
include/linux/quota.h | 2 +-
mm/shmem.c | 7 +------
6 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index afee70125ae3..73caa8914ebe 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1571,15 +1571,13 @@ static int __init ocfs2_init(void)
ocfs2_set_locking_protocol();
- status = register_quota_format(&ocfs2_quota_format);
- if (status < 0)
- goto out3;
+ register_quota_format(&ocfs2_quota_format);
+
status = register_filesystem(&ocfs2_fs_type);
if (!status)
return 0;
unregister_quota_format(&ocfs2_quota_format);
-out3:
debugfs_remove(ocfs2_debugfs_root);
ocfs2_free_mem_caches();
out2:
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 23fcf9e9d6c5..a08a71890cd8 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -163,13 +163,12 @@ static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES;
/* SLAB cache for dquot structures */
static struct kmem_cache *dquot_cachep;
-int register_quota_format(struct quota_format_type *fmt)
+void register_quota_format(struct quota_format_type *fmt)
{
spin_lock(&dq_list_lock);
fmt->qf_next = quota_formats;
quota_formats = fmt;
spin_unlock(&dq_list_lock);
- return 0;
}
EXPORT_SYMBOL(register_quota_format);
diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
index 3f3e8acc05db..6f7f0b4afba9 100644
--- a/fs/quota/quota_v1.c
+++ b/fs/quota/quota_v1.c
@@ -235,7 +235,8 @@ static struct quota_format_type v1_quota_format = {
static int __init init_v1_quota_format(void)
{
- return register_quota_format(&v1_quota_format);
+ register_quota_format(&v1_quota_format);
+ return 0;
}
static void __exit exit_v1_quota_format(void)
diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index c48c233f3bef..1fda93dcbc1b 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -440,12 +440,9 @@ static struct quota_format_type v2r1_quota_format = {
static int __init init_v2_quota_format(void)
{
- int ret;
-
- ret = register_quota_format(&v2r0_quota_format);
- if (ret)
- return ret;
- return register_quota_format(&v2r1_quota_format);
+ register_quota_format(&v2r0_quota_format);
+ register_quota_format(&v2r1_quota_format);
+ return 0;
}
static void __exit exit_v2_quota_format(void)
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 07071e64abf3..89a0d83ddad0 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -526,7 +526,7 @@ struct quota_info {
const struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */
};
-int register_quota_format(struct quota_format_type *fmt);
+void register_quota_format(struct quota_format_type *fmt);
void unregister_quota_format(struct quota_format_type *fmt);
struct quota_module_name {
diff --git a/mm/shmem.c b/mm/shmem.c
index a8b181a63402..d27104e1af9b 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4660,11 +4660,7 @@ void __init shmem_init(void)
shmem_init_inodecache();
#ifdef CONFIG_TMPFS_QUOTA
- error = register_quota_format(&shmem_quota_format);
- if (error < 0) {
- pr_err("Could not register quota format\n");
- goto out3;
- }
+ register_quota_format(&shmem_quota_format);
#endif
error = register_filesystem(&shmem_fs_type);
@@ -4693,7 +4689,6 @@ void __init shmem_init(void)
out2:
#ifdef CONFIG_TMPFS_QUOTA
unregister_quota_format(&shmem_quota_format);
-out3:
#endif
shmem_destroy_inodecache();
shm_mnt = ERR_PTR(error);
--
2.30.0
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 2/4] quota: remove unneeded return value of register_quota_format
2024-07-15 13:05 ` [PATCH 2/4] quota: remove unneeded return value of register_quota_format Kemeng Shi
@ 2024-07-16 1:19 ` Joseph Qi
0 siblings, 0 replies; 9+ messages in thread
From: Joseph Qi @ 2024-07-16 1:19 UTC (permalink / raw)
To: Kemeng Shi, jack
Cc: mark, jlbec, hughd, akpm, ocfs2-devel, linux-kernel, linux-mm
Looks good.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
On 7/15/24 9:05 PM, Kemeng Shi wrote:
> The register_quota_format always returns 0, simply remove unneeded return
> value.
>
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
> fs/ocfs2/super.c | 6 ++----
> fs/quota/dquot.c | 3 +--
> fs/quota/quota_v1.c | 3 ++-
> fs/quota/quota_v2.c | 9 +++------
> include/linux/quota.h | 2 +-
> mm/shmem.c | 7 +------
> 6 files changed, 10 insertions(+), 20 deletions(-)
>
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index afee70125ae3..73caa8914ebe 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -1571,15 +1571,13 @@ static int __init ocfs2_init(void)
>
> ocfs2_set_locking_protocol();
>
> - status = register_quota_format(&ocfs2_quota_format);
> - if (status < 0)
> - goto out3;
> + register_quota_format(&ocfs2_quota_format);
> +
> status = register_filesystem(&ocfs2_fs_type);
> if (!status)
> return 0;
>
> unregister_quota_format(&ocfs2_quota_format);
> -out3:
> debugfs_remove(ocfs2_debugfs_root);
> ocfs2_free_mem_caches();
> out2:
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 23fcf9e9d6c5..a08a71890cd8 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -163,13 +163,12 @@ static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES;
> /* SLAB cache for dquot structures */
> static struct kmem_cache *dquot_cachep;
>
> -int register_quota_format(struct quota_format_type *fmt)
> +void register_quota_format(struct quota_format_type *fmt)
> {
> spin_lock(&dq_list_lock);
> fmt->qf_next = quota_formats;
> quota_formats = fmt;
> spin_unlock(&dq_list_lock);
> - return 0;
> }
> EXPORT_SYMBOL(register_quota_format);
>
> diff --git a/fs/quota/quota_v1.c b/fs/quota/quota_v1.c
> index 3f3e8acc05db..6f7f0b4afba9 100644
> --- a/fs/quota/quota_v1.c
> +++ b/fs/quota/quota_v1.c
> @@ -235,7 +235,8 @@ static struct quota_format_type v1_quota_format = {
>
> static int __init init_v1_quota_format(void)
> {
> - return register_quota_format(&v1_quota_format);
> + register_quota_format(&v1_quota_format);
> + return 0;
> }
>
> static void __exit exit_v1_quota_format(void)
> diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
> index c48c233f3bef..1fda93dcbc1b 100644
> --- a/fs/quota/quota_v2.c
> +++ b/fs/quota/quota_v2.c
> @@ -440,12 +440,9 @@ static struct quota_format_type v2r1_quota_format = {
>
> static int __init init_v2_quota_format(void)
> {
> - int ret;
> -
> - ret = register_quota_format(&v2r0_quota_format);
> - if (ret)
> - return ret;
> - return register_quota_format(&v2r1_quota_format);
> + register_quota_format(&v2r0_quota_format);
> + register_quota_format(&v2r1_quota_format);
> + return 0;
> }
>
> static void __exit exit_v2_quota_format(void)
> diff --git a/include/linux/quota.h b/include/linux/quota.h
> index 07071e64abf3..89a0d83ddad0 100644
> --- a/include/linux/quota.h
> +++ b/include/linux/quota.h
> @@ -526,7 +526,7 @@ struct quota_info {
> const struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */
> };
>
> -int register_quota_format(struct quota_format_type *fmt);
> +void register_quota_format(struct quota_format_type *fmt);
> void unregister_quota_format(struct quota_format_type *fmt);
>
> struct quota_module_name {
> diff --git a/mm/shmem.c b/mm/shmem.c
> index a8b181a63402..d27104e1af9b 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -4660,11 +4660,7 @@ void __init shmem_init(void)
> shmem_init_inodecache();
>
> #ifdef CONFIG_TMPFS_QUOTA
> - error = register_quota_format(&shmem_quota_format);
> - if (error < 0) {
> - pr_err("Could not register quota format\n");
> - goto out3;
> - }
> + register_quota_format(&shmem_quota_format);
> #endif
>
> error = register_filesystem(&shmem_fs_type);
> @@ -4693,7 +4689,6 @@ void __init shmem_init(void)
> out2:
> #ifdef CONFIG_TMPFS_QUOTA
> unregister_quota_format(&shmem_quota_format);
> -out3:
> #endif
> shmem_destroy_inodecache();
> shm_mnt = ERR_PTR(error);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/4] quota: remove redundant return at end of void function
2024-07-15 13:05 [PATCH 0/4] Fix and cleanups to quota Kemeng Shi
2024-07-15 13:05 ` [PATCH 1/4] quota: avoid missing put_quota_format when DQUOT_SUSPENDED is passed Kemeng Shi
2024-07-15 13:05 ` [PATCH 2/4] quota: remove unneeded return value of register_quota_format Kemeng Shi
@ 2024-07-15 13:05 ` Kemeng Shi
2024-07-15 13:05 ` [PATCH 4/4] quota: remove unnecessary error code translation in dquot_quota_enable Kemeng Shi
2024-07-17 13:12 ` [PATCH 0/4] Fix and cleanups to quota Jan Kara
4 siblings, 0 replies; 9+ messages in thread
From: Kemeng Shi @ 2024-07-15 13:05 UTC (permalink / raw)
To: jack
Cc: mark, jlbec, joseph.qi, hughd, akpm, ocfs2-devel, linux-kernel, linux-mm
Function dquot_claim_space_nodirty nad dquot_reclaim_space_nodirty have
no return value, just remove redundant return at end of the functions.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/quota/dquot.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index a08a71890cd8..2ca1f16689de 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1830,7 +1830,6 @@ void dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
spin_unlock(&inode->i_lock);
mark_all_dquot_dirty(dquots);
srcu_read_unlock(&dquot_srcu, index);
- return;
}
EXPORT_SYMBOL(dquot_claim_space_nodirty);
@@ -1872,7 +1871,6 @@ void dquot_reclaim_space_nodirty(struct inode *inode, qsize_t number)
spin_unlock(&inode->i_lock);
mark_all_dquot_dirty(dquots);
srcu_read_unlock(&dquot_srcu, index);
- return;
}
EXPORT_SYMBOL(dquot_reclaim_space_nodirty);
--
2.30.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/4] quota: remove unnecessary error code translation in dquot_quota_enable
2024-07-15 13:05 [PATCH 0/4] Fix and cleanups to quota Kemeng Shi
` (2 preceding siblings ...)
2024-07-15 13:05 ` [PATCH 3/4] quota: remove redundant return at end of void function Kemeng Shi
@ 2024-07-15 13:05 ` Kemeng Shi
2024-07-17 13:12 ` [PATCH 0/4] Fix and cleanups to quota Jan Kara
4 siblings, 0 replies; 9+ messages in thread
From: Kemeng Shi @ 2024-07-15 13:05 UTC (permalink / raw)
To: jack
Cc: mark, jlbec, joseph.qi, hughd, akpm, ocfs2-devel, linux-kernel, linux-mm
Simply set error code to -EEXIST when quota limit is already enabled in
dquot_quota_enable to remove unnecessary error code translation.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/quota/dquot.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 2ca1f16689de..fdf19360ffc9 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2598,7 +2598,8 @@ static int dquot_quota_enable(struct super_block *sb, unsigned int flags)
goto out_err;
}
if (sb_has_quota_limits_enabled(sb, type)) {
- ret = -EBUSY;
+ /* compatible with XFS */
+ ret = -EEXIST;
goto out_err;
}
spin_lock(&dq_state_lock);
@@ -2612,9 +2613,6 @@ static int dquot_quota_enable(struct super_block *sb, unsigned int flags)
if (flags & qtype_enforce_flag(type))
dquot_disable(sb, type, DQUOT_LIMITS_ENABLED);
}
- /* Error code translation for better compatibility with XFS */
- if (ret == -EBUSY)
- ret = -EEXIST;
return ret;
}
--
2.30.0
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 0/4] Fix and cleanups to quota
2024-07-15 13:05 [PATCH 0/4] Fix and cleanups to quota Kemeng Shi
` (3 preceding siblings ...)
2024-07-15 13:05 ` [PATCH 4/4] quota: remove unnecessary error code translation in dquot_quota_enable Kemeng Shi
@ 2024-07-17 13:12 ` Jan Kara
4 siblings, 0 replies; 9+ messages in thread
From: Jan Kara @ 2024-07-17 13:12 UTC (permalink / raw)
To: Kemeng Shi
Cc: jack, mark, jlbec, joseph.qi, hughd, akpm, ocfs2-devel,
linux-kernel, linux-mm
On Mon 15-07-24 21:05:30, Kemeng Shi wrote:
> This series contains some random fix and cleanups to fs quota. Please
> check respective patches for more detail. Thanks!
>
> Kemeng Shi (4):
> quota: avoid missing put_quota_format when DQUOT_SUSPENDED is passed
> quota: remove unneeded return value of register_quota_format
> quota: remove redundant return at end of void function
> quota: remove unnecessary error code translation in dquot_quota_enable
Thanks! All the patches look good to me. I'll queue them into my tree.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 9+ messages in thread