Skip to contentSkip to conversation

Replace NFS4ERR_NOTEMPY with NFS4ERR_EXIST

PATCH In review Ni Wenjuan 2 participants 3 messages Mar 19, 2009 – Mar 20, 2009

Subsystems (2)
lore
Share & tools
lore

Ni Wenjuan

author
#0 lore raw

PATCH 1/1 Replace NFS4ERR_NOTEMPY with NFS4ERR_EXIST

Fix a test in rename operation. rename dir1 into existing,nonempty dir2 should return NFS4ERR_EXIST instead got NFS4ERR_NOTEMPTY. RFC says if the target is a directory but not empty, the server will return the error, NFS4ERR_EXIST.

---
 fs/nfsd/nfs4proc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfsd/nfs4proc.c +0 -0
index 9fa60a3..c1e2e22 100644
@@ -605,7 +605,7 @@ nfsd4_rename(struct svc_rqst *rqstp, struct

nfsd4_compound_state *cstate,

/* the underlying filesystem returns different error's than required
* by NFSv4. both save_fh and current_fh have been verified.. */
- if (status == nfserr_isdir)
+ if (status == nfserr_isdir || status == nfserr_notempty)
status = nfserr_exist;
else if ((status == nfserr_notdir) &&

                   (S_ISDIR(cstate->save_fh.fh_dentry->d_inode->i_mode) &&
#1 lore raw
Quoted 3 lines · Ni Wenjuan

Fix a test in rename operation. rename dir1 into existing,nonempty dir2 should return NFS4ERR_EXIST instead got NFS4ERR_NOTEMPTY. RFC says if the target is a directory but not empty, the server will return the error, NFS4ERR_EXIST.

On a second look: could you double-check the client behavior?:
Currently

mkdir subdir
mkdir -p todir/subdir
touch todir/subdir/foo
mv subdir todir/

results (as in the local case) in "Directory not empty". What happens after applying this patch?

--b.

Quoted 23 lines
---
 fs/nfsd/nfs4proc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfsd/nfs4proc.c +1 -1
index 9fa60a3..c1e2e22 100644
@@ -605,7 +605,7 @@ nfsd4_rename(struct svc_rqst *rqstp, struct
 nfsd4_compound_state *cstate,
 
 	/* the underlying filesystem returns different error's than required
 	 * by NFSv4. both save_fh and current_fh have been verified.. */
-	if (status == nfserr_isdir)
+	if (status == nfserr_isdir || status == nfserr_notempty)
 		status = nfserr_exist;
 	else if ((status == nfserr_notdir) &&
                   (S_ISDIR(cstate->save_fh.fh_dentry->d_inode->i_mode) &&
author
#2 lore raw

J. Bruce Fields =E5=86=99=E9=81=93:

Quoted 2 lines · Ni Wenjuan
Quoted 1 line

Fix a test in rename operation. rename dir1 into existing,nonempty d=

ir2 should

Quoted 1 line
Quoted 1 line

return NFS4ERR_EXIST instead got NFS4ERR_NOTEMPTY. RFC says if the =

target is a

Quoted 1 line
Quoted 1 line

directory but not empty, the server will return the error, NFS4ERR_E=

XIST.

Quoted 10 lines

=20
On a second look: could you double-check the client behavior?:
Currently
=20
mkdir subdir
mkdir -p todir/subdir
touch todir/subdir/foo
mv subdir todir/
=20
results (as in the local case) in "Directory not empty". What happen=

s

Quoted 3 lines

after applying this patch?
=20
--b.

before patch, if you execute "mv subdir todir/" ,client (as in the lo= cal case)=20
will notices you that cannot move 'subdir' to a subdirectory of itself=20 ,'todir/subdie'.

after applying patch, if you execute "mv subdir todir/" ,it will notic= es you=20
that can't move 'subdir to todir/subdir' :File exists .

Quoted 7 lines

=20

Quoted 6 lines
---
 fs/nfsd/nfs4proc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 8 lines

fs/nfsd/nfs4proc.c nfsd4_rename(struct svc_rqst *rqstp, struct · line 607

Quoted 8 lines
fs/nfsd/nfs4proc.c +0 -0
index 9fa60a3..c1e2e22 100644
@@ -605,7 +605,7 @@ nfsd4_rename(struct svc_rqst *rqstp, struct
 nfsd4_compound_state *cstate,
 
 	/* the underlying filesystem returns different error's than requir=

ed

Quoted 6 lines
Quoted 6 lines
fs/nfsd/nfs4proc.c +1 -1
 	 * by NFSv4. both save_fh and current_fh have been verified.. */
-	if (status =3D=3D nfserr_isdir)
+	if (status =3D=3D nfserr_isdir || status =3D=3D nfserr_notempty)
 		status =3D nfserr_exist;
 	else if ((status =3D=3D nfserr_notdir) &&
                   (S_ISDIR(cstate->save_fh.fh_dentry->d_inode->i_mo=

de) &&

Quoted 4 lines
Quoted 2 lines

--=20

=20
=20