All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: historical question: nfs_rename()
@ 2005-10-18 17:59 Lever, Charles
  2005-10-18 18:03 ` Peter Staubach
  2005-10-18 18:11 ` Trond Myklebust
  0 siblings, 2 replies; 10+ messages in thread
From: Lever, Charles @ 2005-10-18 17:59 UTC (permalink / raw)
  To: Peter Staubach, Trond Myklebust; +Cc: nfs

> Actually, this case should fail with EISDIR, as it does.  Mixing
> directory and files in a rename(2) will fail with EISDIR or ENOTDIR.
>=20
> However, renaming one directory to another directory, when the target
> directory is "empty", should not fail.

the specific case i'm whining about today is renaming a directory to an
empty directory.  the desired semantic is that the empty directory will
be replaced.  the existing semantic on the Linux NFS client is that
rename(2) returns -EBUSY.

as far as we can tell, the Solaris client works as desired.  the issue
is a portability problem that arises because Linux's rename(2) doesn't
work precisely the same way as Solaris'.


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: historical question: nfs_rename()
@ 2005-10-18 18:15 Lever, Charles
  2005-10-18 18:36 ` Trond Myklebust
  0 siblings, 1 reply; 10+ messages in thread
From: Lever, Charles @ 2005-10-18 18:15 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: nfs

this is going in the right direction.

should we quickly look at other test cases?  what return code should/do
you get when you try to rename a directory onto a target directory that
still has stuff in it?

have you tested both the file onto directory and directory onto file
cases?


> ty den 18.10.2005 klokka 12:57 (-0400) skreiv Peter Staubach:
> > However, renaming one directory to another directory, when=20
> the target
> > directory is "empty", should not fail.
>=20
> Ah... I see now. OK, so when I rewrite the test case to the attached
> code then it does indeed succeed.
>=20
> The following patch should do the right thing then.
>=20
> Cheers,
>   Trond
>=20
> NFS: Fix rename of directory onto empty directory
>=20
>  If someone tries to rename a directory onto an empty directory, we
>  currently fail and return EBUSY.
>  This patch ensures that we try the rename if both source and target
>  are directories, and that we fail with a correct error of EISDIR if
>  the source is not a directory.
>=20
>  Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
> ---
>  fs/nfs/dir.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>=20
> Index: linux-2.6/fs/nfs/dir.c
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-2.6.orig/fs/nfs/dir.c
> +++ linux-2.6/fs/nfs/dir.c
> @@ -1511,9 +1511,11 @@ static int nfs_rename(struct inode *old_
>  	 */
>  	if (!new_inode)
>  		goto go_ahead;
> -	if (S_ISDIR(new_inode->i_mode))
> -		goto out;
> -	else if (atomic_read(&new_dentry->d_count) > 2) {
> +	if (S_ISDIR(new_inode->i_mode)) {
> +		error =3D -EISDIR;
> +		if (!S_ISDIR(old_inode->i_mode))
> +			goto out;
> +	} else if (atomic_read(&new_dentry->d_count) > 2) {
>  		int err;
>  		/* copy the target dentry's name */
>  		dentry =3D d_alloc(new_dentry->d_parent,
>=20
>=20


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 10+ messages in thread
* historical question: nfs_rename()
@ 2005-10-17 19:12 Lever, Charles
  2005-10-17 19:18 ` Peter Staubach
  2005-10-18 16:10 ` Trond Myklebust
  0 siblings, 2 replies; 10+ messages in thread
From: Lever, Charles @ 2005-10-17 19:12 UTC (permalink / raw)
  To: nfs

a customer recently pointed out that the rename(2) system call does not
allow replacing directories, even if they are empty.  RFC1813 at least
suggests that the server and protocol do allow directory replacement, as
long as the target is empty.

the culprit appears to be this check in nfs_rename()

        if (S_ISDIR(new_inode->i_mode))
                goto out;

which causes nfs_rename() to return -EBUSY if the target is a directory.

is there a historical reason why the Linux NFS client does not allow
directory replacement?  shouldn't the error code be -EISDIR for this
case?

        - Chuck Lever
--
corporate:     <cel at netapp dot com>
personal:      <chucklever at bigfoot dot com>


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-10-18 18:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-18 17:59 historical question: nfs_rename() Lever, Charles
2005-10-18 18:03 ` Peter Staubach
2005-10-18 18:11 ` Trond Myklebust
  -- strict thread matches above, loose matches on Subject: below --
2005-10-18 18:15 Lever, Charles
2005-10-18 18:36 ` Trond Myklebust
2005-10-17 19:12 Lever, Charles
2005-10-17 19:18 ` Peter Staubach
2005-10-18 16:10 ` Trond Myklebust
2005-10-18 16:57   ` Peter Staubach
2005-10-18 18:06     ` Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.