Linux NFS development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Anna Schumaker <Anna.Schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org, Trond.Myklebust@primarydata.com,
	bfields@fieldses.org, hch@infradead.org
Subject: Re: [PATCH v1 2/3] NFSD: Implement the COPY call
Date: Mon, 7 Dec 2015 11:26:46 -0800	[thread overview]
Message-ID: <20151207192646.GB8318@infradead.org> (raw)
In-Reply-To: <1449176137-4940-3-git-send-email-Anna.Schumaker@Netapp.com>

>  static __be32
> +nfsd4_verify_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> +		  struct nfsd4_copy *copy, struct file **src, struct file **dst)
> +{
> +	__be32 status;
> +
> +	status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->save_fh,
> +						&copy->cp_src_stateid, RD_STATE,
> +						src, NULL);
> +	if (status) {
> +		dprintk("NFSD: nfsd4_copy: couldn't process src stateid!\n");
> +		return status;
> +	}
> +
> +	status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh,
> +						&copy->cp_dst_stateid, WR_STATE,
> +						dst, NULL);
> +	if (status) {
> +		dprintk("NFSD: nfsd4_copy: couldn't process dst stateid!\n");
> +		fput(*src);
> +	}

This is missing a return status.  On the clone side that caused really
hard to debug crashes when xfstests hit this case.  While you're at it
I'd suggest to also kill the nfsd4_verify_copy heper.  You might also
need a check for invalid file types that maps to the correct NFS error
code, similar to clone.

> +	if (bytes < 0)
> +		status = nfserrno(bytes);

maybe use a goto here?

> +	else {
> +		copy->cp_res.wr_bytes_written = bytes;
> +		copy->cp_res.wr_stable_how = NFS_FILE_SYNC;
> +		copy->cp_consecutive = 1;

is there anything in the linux semantics that guarantees consecutive
operation?

> +		       u64 count)
> +{
> +	ssize_t bytes;
> +	u64 limit = 0x10000000;
> +
> +	if (count > limit)
> +		count = limit;
> +
> +	bytes = vfs_copy_file_range(src, src_pos, dst, dst_pos, count, 0);
> +	if (bytes > 0)
> +		vfs_fsync_range(dst, dst_pos, dst_pos + bytes, 0);
> +	return bytes;

How about returning NFS_UNSTABLE above and avoiding the fsync here?

  parent reply	other threads:[~2015-12-07 19:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 20:55 [PATCH v1 0/4] NFSv4.2: Add support for the COPY operation Anna Schumaker
2015-12-03 20:55 ` [PATCH v1 1/3] NFSD: Pass filehandle to nfs4_preprocess_stateid_op() Anna Schumaker
2015-12-03 20:55 ` [PATCH v1 2/3] NFSD: Implement the COPY call Anna Schumaker
2015-12-04 15:45   ` J. Bruce Fields
2015-12-04 15:49     ` Anna Schumaker
2015-12-04 16:49       ` J. Bruce Fields
2015-12-04 17:05         ` Anna Schumaker
2015-12-04 17:14           ` J. Bruce Fields
2015-12-07 19:26   ` Christoph Hellwig [this message]
2015-12-07 21:03     ` Anna Schumaker
2015-12-03 20:55 ` [PATCH v1 3/3] NFS: Add COPY nfs operation Anna Schumaker
2015-12-07 19:28   ` Christoph Hellwig
2015-12-03 20:55 ` [RFC v1 4/3] vfs_copy_range() test program Anna Schumaker
2015-12-07 19:23 ` [PATCH v1 0/4] NFSv4.2: Add support for the COPY operation Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151207192646.GB8318@infradead.org \
    --to=hch@infradead.org \
    --cc=Anna.Schumaker@netapp.com \
    --cc=Trond.Myklebust@primarydata.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox