[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230629110813.kfaja4bdomilmns6@quack3>
Date: Thu, 29 Jun 2023 13:08:13 +0200
From: Jan Kara <jack@...e.cz>
To: Baokun Li <libaokun1@...wei.com>
Cc: jack@...e.cz, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
yi.zhang@...wei.com, yangerkun@...wei.com, chengzhihao1@...wei.com,
yukuai3@...wei.com
Subject: Re: [PATCH v2 6/7] quota: simplify drop_dquot_ref()
On Wed 28-06-23 21:21:54, Baokun Li wrote:
> Now when dqput() drops the last reference count, it will call
> synchronize_srcu(&dquot_srcu) in quota_release_workfn() to ensure that
> no other user will use the dquot after the last reference count is dropped,
> so we don't need to call synchronize_srcu(&dquot_srcu) in drop_dquot_ref()
> and remove the corresponding logic directly to simplify the code.
Nice simplification! It is also important that dqput() now cannot sleep
which was another reason for the logic with tofree_head in
remove_inode_dquot_ref(). Probably this is good to mention in the
changelog.
> Signed-off-by: Baokun Li <libaokun1@...wei.com>
> ---
> fs/quota/dquot.c | 33 ++++++---------------------------
> 1 file changed, 6 insertions(+), 27 deletions(-)
>
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index e8e702ac64e5..df028fb2ce72 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -1090,8 +1090,7 @@ static int add_dquot_ref(struct super_block *sb, int type)
> * Remove references to dquots from inode and add dquot to list for freeing
> * if we have the last reference to dquot
> */
> -static void remove_inode_dquot_ref(struct inode *inode, int type,
> - struct list_head *tofree_head)
> +static void remove_inode_dquot_ref(struct inode *inode, int type)
> {
> struct dquot **dquots = i_dquot(inode);
> struct dquot *dquot = dquots[type];
> @@ -1100,21 +1099,7 @@ static void remove_inode_dquot_ref(struct inode *inode, int type,
> return;
>
> dquots[type] = NULL;
> - if (list_empty(&dquot->dq_free)) {
> - /*
> - * The inode still has reference to dquot so it can't be in the
> - * free list
> - */
> - spin_lock(&dq_list_lock);
> - list_add(&dquot->dq_free, tofree_head);
> - spin_unlock(&dq_list_lock);
> - } else {
> - /*
> - * Dquot is already in a list to put so we won't drop the last
> - * reference here.
> - */
> - dqput(dquot);
> - }
> + dqput(dquot);
> }
I think you can also just drop remove_inode_dquot_ref() as it is trivial
now and inline it at its only callsite...
Honza
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists