Re: [patch 08/35] fs: icache lock i_count

From: Boaz Harrosh
Date: Tue Oct 19 2010 - 06:16:59 EST


On 10/19/2010 05:42 AM, npiggin@xxxxxxxxx wrote:
> Protect inode->i_count with i_lock, rather than having it atomic.
>
> Signed-off-by: Nick Piggin <npiggin@xxxxxxxxx>
>
> ---
<>
> fs/exofs/inode.c | 12 +++++++---
> fs/exofs/namei.c | 4 ++-
<>
> Index: linux-2.6/fs/exofs/inode.c
> ===================================================================
> --- linux-2.6.orig/fs/exofs/inode.c 2010-10-19 14:17:26.000000000 +1100
> +++ linux-2.6/fs/exofs/inode.c 2010-10-19 14:19:18.000000000 +1100
> @@ -1107,7 +1107,9 @@
>

Hi Nick, Please use -p option in your diff(s) it is a bit hard to follow
and review without the proper function context. These patches are on a git
tree. Why don't you use git to produce and send these patches?

> set_obj_created(oi);
>
> - atomic_dec(&inode->i_count);
> + spin_lock(&inode->i_lock);
> + inode->i_count--;
> + spin_unlock(&inode->i_lock);

I've queued up a patch in Linux-next that will conflict with this.
The patch uses iput() instead.

> wake_up(&oi->i_wq);
> }
>
> @@ -1160,14 +1162,18 @@
> /* increment the refcount so that the inode will still be around when we
> * reach the callback
> */
> - atomic_inc(&inode->i_count);
> + spin_lock(&inode->i_lock);
> + inode->i_count++;
> + spin_unlock(&inode->i_lock);
>
> ios->done = create_done;
> ios->private = inode;
> ios->cred = oi->i_cred;
> ret = exofs_sbi_create(ios);
> if (ret) {
> - atomic_dec(&inode->i_count);
> + spin_lock(&inode->i_lock);
> + inode->i_count--;
> + spin_unlock(&inode->i_lock);

Here too. (iput)

> exofs_put_io_state(ios);
> return ERR_PTR(ret);
> }
> Index: linux-2.6/fs/exofs/namei.c
> ===================================================================
> --- linux-2.6.orig/fs/exofs/namei.c 2010-10-19 14:17:26.000000000 +1100
> +++ linux-2.6/fs/exofs/namei.c 2010-10-19 14:19:18.000000000 +1100
> @@ -153,7 +153,9 @@
>
> inode->i_ctime = CURRENT_TIME;
> inode_inc_link_count(inode);
> - atomic_inc(&inode->i_count);
> + spin_lock(&inode->i_lock);
> + inode->i_count++;

All these will change to inode_get(), right?

> + spin_unlock(&inode->i_lock);
>
> return exofs_add_nondir(dentry, inode);
> }

Thanks
Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/