[Top] [All Lists]

Re: inode/vnode/xfs_inode locking

To: Daniel Moore <dxm@xxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: inode/vnode/xfs_inode locking
From: Russell Cattelan <cattelan@xxxxxxxxxxx>
Date: Wed, 09 Aug 2000 00:16:59 -0500
Cc: linux-xfs@xxxxxxxxxxx
References: <200008090420.OAA88887@xxxxxxxxxxxxxxxxxxxxxxxx>
Reply-to: cattelan@xxxxxxxxxxx
Sender: owner-linux-xfs-announce@xxxxxxxxxxx
Daniel Moore wrote:

> I'm a bit puzzled about what locking needs to be done when
> handling inodes, vnodes and xfs_inodes.
> struct vnode (vnode_t) is a hangover from IRIX, right? And
> the both it and the xfs_inode_t are stored in the linux
> struct inode, right?
> As far as I can see, if I want to access stuff within an
> inode, a vnode or an xfs_inode, I must hold the inode lock
> (use iget, iput, igrab).
> Is that the case?

It really depends upon what your are modifying?
The XFS code it self uses the vnode portion of the now
linux "supers structure" inode.

xfs_inode modifications are protected by xfs_ilock, xfs_iunlock.

Similarly there are locks on the linux inode, dentry and a  global
dcache lock.

> Here's an example (my new code in xfs_ioctl.c simplified for the
> example):
>                 struct nameidata        nd;
>                 path_init(path, 0, &nd);
>                 path_walk(path, &nd);
>                 vp = LINVFS_GET_VP(nd.dentry->d_inode);
>                 path_release(&nd);

Ok I'm really not sure what you need to do here but
just because you have an dentry doesn't necessarily mean you
have all the data structures under it, that all has to be set up.

In fact a dentry may simply have the the cached inode number,
which could then be passed to read_inode, which would then
proceed to set everything up.

Look at the linvfs_*_inode routines in xfs_super.c

> The inode in question is held by the dentry in nd, so it's
> ok to extract the vnode pointer with LINVFS_GET_VP. But when
> I release the nameidata structure, the dentry is freed, and
> therefore I'm expecting vp is unlocked.
> Is there any way to grab the inode before calling path_release
> or do I just have to defer doing the path_release until after
> I'm done with the inode, xfs_inode & vnode?

> I've got almost exactly the same problem when I use fget to
> return a file from a fd and I want to hold onto the associated
> inode, vnode etc.
> Any clarification would be most welcome...
> Ta
> -----------------------------------------------------
>  Daniel Moore                  dxm@xxxxxxx
>  R&D Software Engineer         Phone: +61-3-98348209
>  SGI Performance Tools Group   Fax:   +61-3-98132378
> -----------------------------------------------------

Russell Cattelan

<Prev in Thread] Current Thread [Next in Thread>