diff options
author | Neil Brown <neilb@cse.unsw.edu.au> | 2005-03-30 16:59:12 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-03-30 16:59:12 -0800 |
commit | 3a090f986f1e998a3645dd7f5fd9b7371e439888 (patch) | |
tree | 539a38f6e0cd3ede72d2379751c322598b1c447c | |
parent | 6b756e57399a22b346b0fd6d1ecdc5dd1748daa5 (diff) | |
download | history-3a090f986f1e998a3645dd7f5fd9b7371e439888.tar.gz |
[PATCH] nfsd4: factor out common open_truncate code
Factor out a bit of common code.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/nfsd/nfs4state.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c7cd71d039095f..ce424c54ddb65a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1575,6 +1575,21 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp, return 0; } +static inline int +nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh, + struct nfsd4_open *open) +{ + struct iattr iattr = { + .ia_valid = ATTR_SIZE, + .ia_size = 0, + }; + if (!open->op_truncate) + return 0; + if (!(open->op_share_access & NFS4_SHARE_ACCESS_WRITE)) + return -EINVAL; + return nfsd_setattr(rqstp, fh, &iattr, 0, (time_t)0); +} + static int nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open) { @@ -1592,19 +1607,11 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_sta status = get_write_access(inode); if (status) return nfserrno(status); - if (open->op_truncate) { - struct iattr iattr = { - .ia_valid = ATTR_SIZE, - .ia_size = 0, - }; - status = nfsd_setattr(rqstp, cur_fh, &iattr, 0, - (time_t)0); - if (status) { - put_write_access(inode); - return status; - } + status = nfsd4_truncate(rqstp, cur_fh, open); + if (status) { + put_write_access(inode); + return status; } - /* remember the open */ filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ; set_bit(open->op_share_access, &stp->st_access_bmap); @@ -1737,17 +1744,10 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf if ((status = nfs4_new_open(rqstp, &stp, current_fh, flags))) goto out; init_stateid(stp, fp, open); - if (open->op_truncate) { - struct iattr iattr = { - .ia_valid = ATTR_SIZE, - .ia_size = 0, - }; - status = nfsd_setattr(rqstp, current_fh, &iattr, 0, - (time_t)0); - if (status) { - release_stateid(stp, OPEN_STATE); - goto out; - } + status = nfsd4_truncate(rqstp, current_fh, open); + if (status) { + release_stateid(stp, OPEN_STATE); + goto out; } } memcpy(&open->op_stateid, &stp->st_stateid, sizeof(stateid_t)); |