linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>,
	dedekind1@gmail.com, jack@suse.com
Cc: linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 13/25] ubifs: introduce a field named as budgeted to ubifs_inode
Date: Tue, 21 Jul 2015 22:47:22 +0200	[thread overview]
Message-ID: <55AEAFDA.3000008@nod.at> (raw)
In-Reply-To: <1437467876-22106-14-git-send-email-yangds.fnst@cn.fujitsu.com>

Am 21.07.2015 um 10:37 schrieb Dongsheng Yang:
> There is a long-term pain in ubifs, we have to introduce a
> ui_mutex in ubifs_inode to solve two problems below:
> 
> 1: make some process atomic, such as ubifs_rename.
> 2: make sure we budget space for inode before dirting it.
> 
> About 1, it's true and we have to do it.
> 
> About 2, we can do it better.
> 	There is a ubifs_assert(mutex_is_locked(&ui->mutex)) in
> ubifs_dirty_inode(). But there is probably some processes
> are very long, and we can not make all of it into a pair of
> lock/unlock ui->mutex.
> 
> E.g: dquot_disable().
> 	It would mark the quota files as dirty and write the
> inode back. We can do a budget before this function, but we
> can not make the whole dquot_disable() into mutex_lock/mutex_unlock.
> Because we need to lock the ui_mutex in dquot_disable().
> 
> So, this commit introduce a ui->budgeted to allow us to make
> budgeting and dirting in two different lock windows.
> 
> Result:
> 	ubifs_budget_space()
> 	mutex_lock();
> 	ui->budgeted = 1;
> 	mutex_unlock();
> 	...
> 	dquot_disable();

I'm confused by this changelog.

Why do you need ui->budgeted? You set it but never read it
except in an ubifs_assert().

> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> ---
>  fs/ubifs/file.c  |  7 +++++++
>  fs/ubifs/ioctl.c |  1 +
>  fs/ubifs/super.c | 14 +++++++++++++-
>  fs/ubifs/ubifs.h |  1 +
>  4 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index dc8bf0b..113c3a6 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -307,6 +307,7 @@ static int write_begin_slow(struct address_space *mapping,
>  			 * budget we allocated.
>  			 */
>  			ubifs_release_dirty_inode_budget(c, ui);
> +		ui->budgeted = 1;
>  	}
>  
>  	*pagep = page;
> @@ -357,6 +358,7 @@ static int allocate_budget(struct ubifs_info *c, struct page *page,
>  		 * we need to budget the inode change.
>  		 */
>  		req.dirtied_ino = 1;
> +		ui->budgeted = 1;
>  	} else {
>  		if (PageChecked(page))
>  			/*
> @@ -384,6 +386,7 @@ static int allocate_budget(struct ubifs_info *c, struct page *page,
>  				 * needs a budget.
>  				 */
>  				req.dirtied_ino = 1;
> +			ui->budgeted = 1;
>  		}
>  	}
>  
> @@ -1237,6 +1240,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
>  	do_attr_changes(inode, attr);
>  
>  	release = ui->dirty;
> +	ui->budgeted = 1;
>  	if (attr->ia_valid & ATTR_SIZE)
>  		/*
>  		 * Inode length changed, so we have to make sure
> @@ -1397,6 +1401,7 @@ static int ubifs_update_time(struct inode *inode, struct timespec *time,
>  		iflags |= I_DIRTY_SYNC;
>  
>  	release = ui->dirty;
> +	ui->budgeted = 1;
>  	__mark_inode_dirty(inode, iflags);
>  	mutex_unlock(&ui->ui_mutex);
>  	if (release)
> @@ -1430,6 +1435,7 @@ static int update_mctime(struct inode *inode)
>  		mutex_lock(&ui->ui_mutex);
>  		inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
>  		release = ui->dirty;
> +		ui->budgeted = 1;
>  		mark_inode_dirty_sync(inode);
>  		mutex_unlock(&ui->ui_mutex);
>  		if (release)
> @@ -1556,6 +1562,7 @@ static int ubifs_vm_page_mkwrite(struct vm_area_struct *vma,
>  		mutex_lock(&ui->ui_mutex);
>  		inode->i_mtime = inode->i_ctime = ubifs_current_time(inode);
>  		release = ui->dirty;
> +		ui->budgeted = 1;
>  		mark_inode_dirty_sync(inode);
>  		mutex_unlock(&ui->ui_mutex);
>  		if (release)
> diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
> index 3c7b29d..f015b81 100644
> --- a/fs/ubifs/ioctl.c
> +++ b/fs/ubifs/ioctl.c
> @@ -128,6 +128,7 @@ static int setflags(struct inode *inode, int flags)
>  	ubifs_set_inode_flags(inode);
>  	inode->i_ctime = ubifs_current_time(inode);
>  	release = ui->dirty;
> +	ui->budgeted = 1;
>  	mark_inode_dirty_sync(inode);
>  	mutex_unlock(&ui->ui_mutex);
>  
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 2491fff..5fa21d6 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -331,6 +331,7 @@ static int ubifs_write_inode(struct inode *inode, struct writeback_control *wbc)
>  	}
>  
>  	ui->dirty = 0;
> +	ui->budgeted = 0;
>  	mutex_unlock(&ui->ui_mutex);
>  	ubifs_release_dirty_inode_budget(c, ui);
>  	return err;
> @@ -386,12 +387,23 @@ done:
>  static void ubifs_dirty_inode(struct inode *inode, int flags)
>  {
>          struct ubifs_inode *ui = ubifs_inode(inode);
> +	int need_unlock = 0;
>  
> -	ubifs_assert(mutex_is_locked(&ui->ui_mutex));
> +	if (unlikely(!mutex_is_locked(&ui->ui_mutex))) {
> +		/* We need to lock ui_mutex to access ui->budgeted */
> +		mutex_lock(&ui->ui_mutex);
> +		need_unlock = 1;
> +	}
> +
> +	/* Check the budget for this inode */
> +	ubifs_assert(ui->budgeted);
>  	if (!ui->dirty) {
>  		ui->dirty = 1;
>  		dbg_gen("inode %lu",  inode->i_ino);
>  	}
> +
> +	if (need_unlock)
> +		mutex_unlock(&ui->ui_mutex);
>  }
>  
>  static int ubifs_statfs(struct dentry *dentry, struct kstatfs *buf)
> diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
> index 9754bb6..28392a6 100644
> --- a/fs/ubifs/ubifs.h
> +++ b/fs/ubifs/ubifs.h
> @@ -410,6 +410,7 @@ struct ubifs_inode {
>  	unsigned int xattr_cnt;
>  	unsigned int xattr_names;
>  	unsigned int dirty:1;
> +	unsigned int budgeted:1;

Please document that new flag too.

Thanks,
//richard

  reply	other threads:[~2015-07-21 20:47 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-21  8:37 [RFC PATCH 00/25] Add quota supporting in ubifs Dongsheng Yang
2015-07-21  8:37 ` [PATCH 01/25] fs: introduce a ->s_cdev field into struct super_block Dongsheng Yang
2015-07-21  8:37 ` [PATCH 02/25] ubi: introduce a interface to get cdev in ubi_volume Dongsheng Yang
2015-07-21  8:37 ` [PATCH 03/25] ubifs: fill sb->s_cdev in ubifs_fill_super() Dongsheng Yang
2015-07-21  8:37 ` [PATCH 04/25] fs: super: introduce the functions to get super by cdev reference Dongsheng Yang
2015-07-21  9:04   ` Jan Kara
2015-07-22  0:37     ` Dongsheng Yang
2015-07-21  8:37 ` [PATCH 05/25] fs: char_dev: introduce lookup_cdev function to find cdev by name Dongsheng Yang
2015-07-21  9:20   ` Jan Kara
2015-07-21  8:37 ` [PATCH 06/25] fs: dquot: skip invalidate_bdev if bdev is NULL Dongsheng Yang
2015-07-21  8:37 ` [PATCH 07/25] fs: quota: make quota support fs which is running on char dev Dongsheng Yang
2015-07-21  8:37 ` [PATCH 08/25] ubifs: fix a typo in comment of ubifs_budget_req Dongsheng Yang
2015-07-21  8:37 ` [PATCH 09/25] ubifs: extend budget for blocks Dongsheng Yang
2015-07-21  8:37 ` [PATCH 10/25] ubifs: fill ->s_dev in ubifs_fill_super Dongsheng Yang
2015-07-21  8:37 ` [PATCH 11/25] ubifs: export read_block() from file.c Dongsheng Yang
2015-07-21 20:36   ` Richard Weinberger
2015-07-22  0:41     ` Dongsheng Yang
2015-07-21  8:37 ` [PATCH 12/25] ubifs: introduce quota related mount options Dongsheng Yang
2015-07-21 20:39   ` Richard Weinberger
2015-07-22  0:41     ` Dongsheng Yang
2015-07-21  8:37 ` [PATCH 13/25] ubifs: introduce a field named as budgeted to ubifs_inode Dongsheng Yang
2015-07-21 20:47   ` Richard Weinberger [this message]
2015-07-22  0:56     ` Dongsheng Yang
2015-07-22  6:22       ` Dongsheng Yang
2015-07-21  8:37 ` [PATCH 14/25] ubifs: implement IO functions for quota files Dongsheng Yang
2015-07-21  8:37 ` [PATCH 15/25] ubifs: disable quota in ubifs_put_super Dongsheng Yang
2015-07-21  8:37 ` [PATCH 16/25] ubifs: write quota back in ubifs_sync Dongsheng Yang
2015-07-21  8:37 ` [PATCH 17/25] ubifs: suspend & resume quota properly in ubifs_remount Dongsheng Yang
2015-07-21  8:37 ` [PATCH 18/25] ubifs: record quota information about inode in ubifs_new_inode Dongsheng Yang
2015-07-21  8:37 ` [PATCH 19/25] ubifs: free quota inode information in ubifs_evict_inode Dongsheng Yang
2015-07-21  8:37 ` [PATCH 20/25] ubifs: alloc quota space in ubifs_write_begin Dongsheng Yang
2015-07-21  8:37 ` [PATCH 21/25] ubifs: free quota space in do_truncation and unlink Dongsheng Yang
2015-07-21  8:37 ` [PATCH 22/25] ubifs: adapt quota space informatin in do_setattr Dongsheng Yang
2015-07-21  8:37 ` [PATCH 23/25] ubifs: transfer quota information in changing owner or group Dongsheng Yang
2015-07-21  8:37 ` [PATCH 24/25] ubifs: implement ubifs_qctl_operations for quotactl Dongsheng Yang
2015-07-21  8:37 ` [PATCH 25/25] ubifs: make ubifs to support quota Dongsheng Yang
2015-07-21  8:58 ` [RFC PATCH 00/25] Add quota supporting in ubifs Jan Kara
2015-07-22  0:56   ` Dongsheng Yang
2015-07-21 20:50 ` Richard Weinberger
2015-07-22  1:11   ` Dongsheng Yang
2015-07-21 21:01 ` Richard Weinberger
2015-07-22  0:58   ` Dongsheng Yang
2015-07-21 21:15 ` Richard Weinberger
2015-07-22  0:58   ` Dongsheng Yang
2015-07-22  6:58     ` Richard Weinberger
2015-07-22 11:23 ` Dongsheng Yang
2015-07-22 14:13   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55AEAFDA.3000008@nod.at \
    --to=richard@nod.at \
    --cc=dedekind1@gmail.com \
    --cc=jack@suse.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=yangds.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).