Delay in WRITE delegation recall during COMMIT
Ajay Gulati
gulati at rice.edu
Fri Aug 18 20:10:50 EDT 2006
Hi Bruce,
I am assuming you meant filp (struct file *), when you mentioned
filehandle. I was wondering if it would be hard to not use nfsd_open()
during nfsd_commit()?
I modified nfsd_commit() to use dentry_open() instead of nfsd_open(). The
same thing as write wasn't possible currently because nfsd4_write has
stateid which makes it easy to get filp. The "COMMIT" only has offset and
count.
I am attaching the patch below, which seems to work. I modified __setlease()
also to get write delegation and test the patch. I am looking into making
delegations work without the modification in __setlease(), if you have any
ideas on that please let me know.
nfsd-spec/vfs.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff -puN vfs.c~commit-breaklease vfs.c
--- nfsd/vfs.c~commit-breaklease 2006-08-18 14:31:13.000000000 -0700
+++ nfsd-spec/vfs.c 2006-08-18 14:31:55.000000000 -0700
@@ -1052,22 +1052,27 @@ nfsd_commit(struct svc_rqst *rqstp, stru
loff_t offset, unsigned long count)
{
struct file *file;
- int err;
+ int err = nfs_ok;
if ((u64)count > ~(u64)offset)
return nfserr_inval;
+ if (!EX_ISSYNC(fhp->fh_export))
+ return nfs_ok;
- if ((err = nfsd_open(rqstp, fhp, S_IFREG, MAY_WRITE, &file)) != 0)
+ err = nfsd_permission(fhp->fh_export, fhp->fh_dentry,
+ MAY_WRITE|MAY_OWNER_OVERRIDE);
+ if (err)
return err;
- if (EX_ISSYNC(fhp->fh_export)) {
- if (file->f_op && file->f_op->fsync) {
- err = nfserrno(nfsd_sync(file));
- } else {
- err = nfserr_notsupp;
- }
- }
+ file = dentry_open(dget(fhp->fh_dentry),
mntget(fhp->fh_export->ex_mnt),
+ O_WRONLY | O_LARGEFILE);
+ if (IS_ERR(file))
+ return nfserrno(PTR_ERR(file));
+ if (file->f_op && file->f_op->fsync)
+ err = nfserrno(nfsd_sync(file));
+ else
+ err = nfserr_notsupp;
- nfsd_close(file);
+ fput(file);
return err;
}
#endif /* CONFIG_NFSD_V3 */
Thanks for your comments and suggestions.
-Ajay
On 8/18/06, J. Bruce Fields <bfields at fieldses.org> wrote:
>
> On Fri, Aug 18, 2006 at 12:09:53PM -0500, Ajay Gulati wrote:
> > Hi Bruce,
> > You are right, the linux kernel doesn't give out write delegations. I
> > had been playing with write delegations and had
> > modified the code in __setlease() to make it work. I thought I had
> removed
> > that patch for my current testing but when you mentioned it, I went back
> > and checked again just to find that it was compiled in by mistake. Here
> is
> > the change in __setlease() (fs/locks.c) that caused write delegation to
> > be granted.
> >
> > if ((arg == F_WRLCK)
> > && ((atomic_read(&dentry->d_count) > 2)
> > || (atomic_read(&inode->i_count) > 2)))
> > goto out;
>
> Sounds like some more changes are needed to get write delegations
> working properly. To handle this particular problem, maybe
> nfsd_commit() needs to have the option of taking a filehandle (as does
> nfsd_write() now, for example) so that it doesn't have to do a new open?
> I'm not sure.
>
> --b.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://linux-nfs.org/pipermail/nfsv4/attachments/20060818/81fd47e6/attachment.htm
More information about the NFSv4
mailing list