linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Stroetmann <stroetmann@ontolinux.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 06/20] fs: Clean up inode reference counting
Date: Tue, 19 Oct 2010 01:53:13 +0200	[thread overview]
Message-ID: <4CBCDDE9.6010402@ontolinux.com> (raw)
In-Reply-To: <1287382856-29529-7-git-send-email-david@fromorbit.com>

  Just only typos

On the 18.10.2010 08:20, Dave Chinner wrote:
> From: Dave Chinner<dchinner@redhat.com>
>
> Lots of filesystem code open codes the act of getting a reference to
> an inode.  Factor the open coded inode lock, increment, unlock into
> a function iref(). This removes most direct external references to
> the inode reference count.
>
> Originally based on a patch from Nick Piggin.
>
> Signed-off-by: Dave Chinner<dchinner@redhat.com>
> Reviewed-by: Christoph Hellwig<hch@lst.de>
> ---
>   fs/9p/vfs_inode.c           |    5 +++--
>   fs/affs/inode.c             |    2 +-
>   fs/afs/dir.c                |    2 +-
>   fs/anon_inodes.c            |    7 +------
>   fs/bfs/dir.c                |    2 +-
>   fs/block_dev.c              |   13 ++++++-------
>   fs/btrfs/inode.c            |    2 +-
>   fs/coda/dir.c               |    2 +-
>   fs/drop_caches.c            |    2 +-
>   fs/exofs/inode.c            |    2 +-
>   fs/exofs/namei.c            |    2 +-
>   fs/ext2/namei.c             |    2 +-
>   fs/ext3/namei.c             |    2 +-
>   fs/ext4/namei.c             |    2 +-
>   fs/fs-writeback.c           |    7 +++----
>   fs/gfs2/ops_inode.c         |    2 +-
>   fs/hfsplus/dir.c            |    2 +-
>   fs/inode.c                  |   34 ++++++++++++++++++++++------------
>   fs/jffs2/dir.c              |    4 ++--
>   fs/jfs/jfs_txnmgr.c         |    2 +-
>   fs/jfs/namei.c              |    2 +-
>   fs/libfs.c                  |    2 +-
>   fs/logfs/dir.c              |    2 +-
>   fs/minix/namei.c            |    2 +-
>   fs/namei.c                  |    2 +-
>   fs/nfs/dir.c                |    2 +-
>   fs/nfs/getroot.c            |    2 +-
>   fs/nfs/write.c              |    2 +-
>   fs/nilfs2/namei.c           |    2 +-
>   fs/notify/inode_mark.c      |    8 ++++----
>   fs/ntfs/super.c             |    4 ++--
>   fs/ocfs2/namei.c            |    2 +-
>   fs/quota/dquot.c            |    2 +-
>   fs/reiserfs/namei.c         |    2 +-
>   fs/sysv/namei.c             |    2 +-
>   fs/ubifs/dir.c              |    2 +-
>   fs/udf/namei.c              |    2 +-
>   fs/ufs/namei.c              |    2 +-
>   fs/xfs/linux-2.6/xfs_iops.c |    2 +-
>   fs/xfs/xfs_inode.h          |    2 +-
>   include/linux/fs.h          |    2 +-
>   ipc/mqueue.c                |    2 +-
>   kernel/futex.c              |    2 +-
>   mm/shmem.c                  |    2 +-
>   net/socket.c                |    2 +-
>   45 files changed, 80 insertions(+), 76 deletions(-)
>
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 9e670d5..1f76624 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1789,9 +1789,10 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
>   		kfree(st);
>   	} else {
>   		/* Caching disabled. No need to get upto date stat info.
> -		 * This dentry will be released immediately. So, just i_count++
> +		 * This dentry will be released immediately. So, just take
> +		 * a reference.
>   		 */
> -		atomic_inc(&old_dentry->d_inode->i_count);
> +		iref(old_dentry->d_inode);
>   	}
>
>   	dentry->d_op = old_dentry->d_op;
> diff --git a/fs/affs/inode.c b/fs/affs/inode.c
> index 3a0fdec..2100852 100644
> --- a/fs/affs/inode.c
> +++ b/fs/affs/inode.c
> @@ -388,7 +388,7 @@ affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s3
>   		affs_adjust_checksum(inode_bh, block - be32_to_cpu(chain));
>   		mark_buffer_dirty_inode(inode_bh, inode);
>   		inode->i_nlink = 2;
> -		atomic_inc(&inode->i_count);
> +		iref(inode);
>   	}
>   	affs_fix_checksum(sb, bh);
>   	mark_buffer_dirty_inode(bh, inode);
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 0d38c09..87d8c03 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -1045,7 +1045,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
>   	if (ret<  0)
>   		goto link_error;
>
> -	atomic_inc(&vnode->vfs_inode.i_count);
> +	iref(&vnode->vfs_inode);
>   	d_instantiate(dentry,&vnode->vfs_inode);
>   	key_put(key);
>   	_leave(" = 0");
> diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
> index e4b75d6..451be78 100644
> --- a/fs/anon_inodes.c
> +++ b/fs/anon_inodes.c
> @@ -109,12 +109,7 @@ struct file *anon_inode_getfile(const char *name,
>   		goto err_module;
>
>   	path.mnt = mntget(anon_inode_mnt);
> -	/*
> -	 * We know the anon_inode inode count is always greater than zero,
> -	 * so we can avoid doing an igrab() and we can use an open-coded
> -	 * atomic_inc().
> -	 */
> -	atomic_inc(&anon_inode_inode->i_count);
> +	iref(anon_inode_inode);
>
>   	path.dentry->d_op =&anon_inodefs_dentry_operations;
>   	d_instantiate(path.dentry, anon_inode_inode);
> diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
> index d967e05..6e93a37 100644
> --- a/fs/bfs/dir.c
> +++ b/fs/bfs/dir.c
> @@ -176,7 +176,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
>   	inc_nlink(inode);
>   	inode->i_ctime = CURRENT_TIME_SEC;
>   	mark_inode_dirty(inode);
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>   	d_instantiate(new, inode);
>   	mutex_unlock(&info->bfs_lock);
>   	return 0;
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 63b1c4c..11ad53d 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -565,7 +565,7 @@ EXPORT_SYMBOL(bdget);
>    */
>   struct block_device *bdgrab(struct block_device *bdev)
>   {
> -	atomic_inc(&bdev->bd_inode->i_count);
> +	iref(bdev->bd_inode);
>   	return bdev;
>   }
>
> @@ -595,7 +595,7 @@ static struct block_device *bd_acquire(struct inode *inode)
>   	spin_lock(&bdev_lock);
>   	bdev = inode->i_bdev;
>   	if (bdev) {
> -		atomic_inc(&bdev->bd_inode->i_count);
> +		bdgrab(bdev);
>   		spin_unlock(&bdev_lock);
>   		return bdev;
>   	}
> @@ -606,12 +606,11 @@ static struct block_device *bd_acquire(struct inode *inode)
>   		spin_lock(&bdev_lock);
>   		if (!inode->i_bdev) {
>   			/*
> -			 * We take an additional bd_inode->i_count for inode,
> -			 * and it's released in clear_inode() of inode.
> -			 * So, we can access it via ->i_mapping always
> -			 * without igrab().
> +			 * We take an additional bdev reference here so
> +			 * we can access it via ->i_mapping always
> +			 * without first needing to grab a reference.
>   			 */
> -			atomic_inc(&bdev->bd_inode->i_count);
> +			bdgrab(bdev);
>   			inode->i_bdev = bdev;
>   			inode->i_mapping = bdev->bd_inode->i_mapping;
>   			list_add(&inode->i_devices,&bdev->bd_inodes);
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index c038644..80e28bf 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4758,7 +4758,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
>   	}
>
>   	btrfs_set_trans_block_group(trans, dir);
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>
>   	err = btrfs_add_nondir(trans, dentry, inode, 1, index);
>
> diff --git a/fs/coda/dir.c b/fs/coda/dir.c
> index ccd98b0..ac8b913 100644
> --- a/fs/coda/dir.c
> +++ b/fs/coda/dir.c
> @@ -303,7 +303,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
>   	}
>
>   	coda_dir_update_mtime(dir_inode);
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>   	d_instantiate(de, inode);
>   	inc_nlink(inode);
>
> diff --git a/fs/drop_caches.c b/fs/drop_caches.c
> index 2195c21..c2721fa 100644
> --- a/fs/drop_caches.c
> +++ b/fs/drop_caches.c
> @@ -22,7 +22,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
>   			continue;
>   		if (inode->i_mapping->nrpages == 0)
>   			continue;
> -		__iget(inode);
> +		atomic_inc(&inode->i_count);
>   		spin_unlock(&inode_lock);
>   		invalidate_mapping_pages(inode->i_mapping, 0, -1);
>   		iput(toput_inode);
> diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
> index eb7368e..b631ff3 100644
> --- a/fs/exofs/inode.c
> +++ b/fs/exofs/inode.c
> @@ -1154,7 +1154,7 @@ struct inode *exofs_new_inode(struct inode *dir, int mode)
>   	/* increment the refcount so that the inode will still be around when we
>   	 * reach the callback
>   	 */
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>
>   	ios->done = create_done;
>   	ios->private = inode;
> diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
> index b7dd0c2..f2a30a0 100644
> --- a/fs/exofs/namei.c
> +++ b/fs/exofs/namei.c
> @@ -153,7 +153,7 @@ static int exofs_link(struct dentry *old_dentry, struct inode *dir,
>
>   	inode->i_ctime = CURRENT_TIME;
>   	inode_inc_link_count(inode);
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>
>   	return exofs_add_nondir(dentry, inode);
>   }
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index 71efb0e..b15435f 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -206,7 +206,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
>
>   	inode->i_ctime = CURRENT_TIME_SEC;
>   	inode_inc_link_count(inode);
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>
>   	err = ext2_add_link(dentry, inode);
>   	if (!err) {
> diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
> index 2b35ddb..6c7a5d6 100644
> --- a/fs/ext3/namei.c
> +++ b/fs/ext3/namei.c
> @@ -2260,7 +2260,7 @@ retry:
>
>   	inode->i_ctime = CURRENT_TIME_SEC;
>   	inc_nlink(inode);
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>
>   	err = ext3_add_entry(handle, dentry, inode);
>   	if (!err) {
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 314c0d3..a406a85 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2312,7 +2312,7 @@ retry:
>
>   	inode->i_ctime = ext4_current_time(inode);
>   	ext4_inc_count(handle, inode);
> -	atomic_inc(&inode->i_count);
> +	iref(inode);
>
>   	err = ext4_add_entry(handle, dentry, inode);
>   	if (!err) {
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 92d73b6..595dfc6 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -298,8 +298,7 @@ static void inode_wait_for_writeback(struct inode *inode)
>
>   /*
>    * Write out an inode's dirty pages.  Called under inode_lock.  Either the
Don't know exactly:
Write out an inode's dirty page
or
Write out on inode's dirty pages
> - * caller has ref on the inode (either via __iget or via syscall against an fd)
> - * or the inode has I_WILL_FREE set (via generic_forget_inode)
> + * caller has a reference on the inode or the inode has I_WILL_FREE set.
>    *
>    * If `wait' is set, wait on the writeout.
>    *
[...]

  reply	other threads:[~2010-10-18 23:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-18  6:20 Inode Lock Scalability V5 Dave Chinner
2010-10-18  6:20 ` [PATCH 01/20] fs: switch bdev inode bdi's correctly Dave Chinner
2010-10-18 23:52   ` Christian Stroetmann
2010-10-18  6:20 ` [PATCH 02/20] kernel: add bl_list Dave Chinner
2010-10-18  6:20 ` [PATCH 03/20] fs: Convert nr_inodes and nr_unused to per-cpu counters Dave Chinner
2010-10-18  6:20 ` [PATCH 04/20] fs: Implement lazy LRU updates for inodes Dave Chinner
2010-10-18 23:52   ` Christian Stroetmann
2010-10-18  6:20 ` [PATCH 05/20] fs: inode split IO and LRU lists Dave Chinner
2010-10-18  6:20 ` [PATCH 06/20] fs: Clean up inode reference counting Dave Chinner
2010-10-18 23:53   ` Christian Stroetmann [this message]
2010-10-19 19:38   ` Christoph Hellwig
2010-10-18  6:20 ` [PATCH 07/20] exofs: use iput() for inode reference count decrements Dave Chinner
2010-10-18  6:20 ` [PATCH 08/20] fs: rework icount to be a locked variable Dave Chinner
2010-10-18  6:20 ` [PATCH 09/20] fs: Factor inode hash operations into functions Dave Chinner
2010-10-18  6:20 ` [PATCH 10/20] fs: Stop abusing find_inode_fast in iunique Dave Chinner
2010-10-18  6:20 ` [PATCH 11/20] fs: move i_ref increments into find_inode/find_inode_fast Dave Chinner
2010-10-18  6:20 ` [PATCH 12/20] fs: remove inode_add_to_list/__inode_add_to_list Dave Chinner
2010-10-18  6:20 ` [PATCH 13/20] fs: Introduce per-bucket inode hash locks Dave Chinner
2010-10-18  6:20 ` [PATCH 14/20] fs: add a per-superblock lock for the inode list Dave Chinner
2010-10-18  6:20 ` [PATCH 15/20] fs: split locking of inode writeback and LRU lists Dave Chinner
2010-10-18 23:53   ` Christian Stroetmann
2010-10-18  6:20 ` [PATCH 16/20] fs: Protect inode->i_state with the inode->i_lock Dave Chinner
2010-10-18  6:20 ` [PATCH 17/20] fs: introduce a per-cpu last_ino allocator Dave Chinner
2010-10-18  6:20 ` [PATCH 18/20] fs: icache remove inode_lock Dave Chinner
2010-10-18 23:54   ` Christian Stroetmann
2010-10-18  6:20 ` [PATCH 19/20] fs: Reduce inode I_FREEING and factor inode disposal Dave Chinner
2010-10-18  6:20 ` [PATCH 20/20] fs: do not assign default i_ino in new_inode Dave Chinner

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=4CBCDDE9.6010402@ontolinux.com \
    --to=stroetmann@ontolinux.com \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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).