[pnfs] [PATCH 1/1] pnfsd: layoutcommit set size fix
Benny Halevy
bhalevy at panasas.com
Thu Mar 6 14:40:50 EST 2008
On Mar. 06, 2008, 21:30 +0200, Ricardo Labiaga <ricardo.labiaga at netapp.com> wrote:
> nfsd4_layoutcommit() should only reset the size of the file if
> the client modified the file size. The client indicates size change
> by setting the no_newoffset field in the LAYOUT_COMMIT message.
>
> Note that the 'no_' prefix stands for "new offset", not for negative.
> If no_newoffset is false while XDR decoding (no file change), we set
> lcp->lc_newoffset to zero to indicate this.
>
> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga at netapp.com>
> ---
> fs/nfsd/nfs4proc.c | 17 +++++++++--------
> 1 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index 033895e..3d1a494 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1094,7 +1094,7 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp,
> dprintk("NFSD: nfsd4_layoutcommit \n");
> status = fh_verify(rqstp, current_fh, 0, MAY_NOP);
> if (status) {
> - printk("%s: verify filehandle failed\n", __FUNCTION__);
> + printk("%s: verify filehandle failed\n", __func__);
I'll leave it as a naked printk for now.
At some point we need to remove all the printk's after fh_verify failed
that are scattered all over the place...
Benny
> goto out;
> }
>
> @@ -1120,11 +1120,12 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp,
> * locks.
> * TODO: Is this correct for all back ends?
> */
> - dprintk("%s:new size: %llu old size: %lld\n",
> - __FUNCTION__, lcp->lc_last_wr + 1, ino->i_size);
> + dprintk("%s:new offset: %d new size: %llu old size: %lld\n",
> + __func__, lcp->lc_newoffset, lcp->lc_last_wr + 1, ino->i_size);
>
> fh_lock(current_fh);
> - if ((lcp->lc_last_wr + 1) <= ino->i_size) {
> + if ((lcp->lc_newoffset == 0) ||
> + ((lcp->lc_last_wr + 1) <= ino->i_size)) {
> status = 0;
> lcp->lc_size_chg = 0;
> fh_unlock(current_fh);
> @@ -1135,15 +1136,15 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp,
> lcp->lc_seg.clientid = *(u64 *)¤t_ses->cs_sid.clientid;
>
> /* Try our best to update the file size */
> - dprintk("%s: Modifying file size\n", __FUNCTION__);
> + dprintk("%s: Modifying file size\n", __func__);
> ia.ia_valid = ATTR_SIZE;
> ia.ia_size = lcp->lc_last_wr + 1;
> if (sb->s_export_op->layout_commit) {
> status = sb->s_export_op->layout_commit(ino, lcp);
> - dprintk("%s:layout_commit result %d\n", __FUNCTION__, status);
> + dprintk("%s:layout_commit result %d\n", __func__, status);
> } else {
> status = notify_change(current_fh->fh_dentry, &ia);
> - dprintk("%s:notify_change result %d\n", __FUNCTION__, status);
> + dprintk("%s:notify_change result %d\n", __func__, status);
> }
>
> fh_unlock(current_fh);
> @@ -1151,7 +1152,7 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp,
> if (!status) {
> if (EX_ISSYNC(current_fh->fh_export)) {
> dprintk("%s:Synchronously writing inode size %llu\n",
> - __FUNCTION__, ino->i_size);
> + __func__, ino->i_size);
> write_inode_now(ino, 1);
> }
> lcp->lc_size_chg = 1;
More information about the pNFS
mailing list