From: Benny Halevy <bhalevy@panasas.com>
To: andros@netapp.com
Cc: pnfs@linux-nfs.org, linux-nfs@vger.kernel.org
Subject: Re: [pnfs] [PATCH 2/2] pnfs: fix pnfs_commit update_layout range
Date: Tue, 03 Nov 2009 08:24:18 +0200 [thread overview]
Message-ID: <4AEFCC92.4050002@panasas.com> (raw)
In-Reply-To: <1256217343-6991-3-git-send-email-andros@netapp.com>
Merged. Thanks!
Benny
On Oct. 22, 2009, 15:15 +0200, andros@netapp.com wrote:
> From: Andy Adamson <andros@netapp.com>
>
> Whole file semantics are different for COMMIT (0,0) and layouts
> (0,NFS4_MAX_UINT64).
>
> Reported-by: Alexandros Batsakis <batsakis@netapp.com>
>
> Translate COMMIT whole file semantics to LAYOUTGET whole file semantics.
>
> The LAYOUTGET request uses u64 length, change pnfs_update_layout() count field
> type to match.
>
> Replace PAGE_SIZE with PAGE_CACHE_SIZE and PAGE_CACHE_SHIFT.
>
> Signed-off-by: Andy Adamson <andros@netapp.com>
> ---
> fs/nfs/pnfs.c | 36 ++++++++++++++++++++++++++++--------
> fs/nfs/pnfs.h | 2 +-
> 2 files changed, 29 insertions(+), 9 deletions(-)
>
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index 674d8b7..ffed515 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -1052,7 +1052,7 @@ void drain_layoutreturns(struct pnfs_layout_type *lo)
> int
> pnfs_update_layout(struct inode *ino,
> struct nfs_open_context *ctx,
> - size_t count,
> + u64 count,
> loff_t pos,
> enum pnfs_iomode iomode,
> struct pnfs_layout_segment **lsegpp)
> @@ -1518,17 +1518,29 @@ pnfs_update_layout_commit(struct inode *inode,
> {
> struct nfs_server *nfss = NFS_SERVER(inode);
> struct nfs_page *nfs_page = nfs_list_entry(head->next);
> + u64 count;
> + loff_t start;
> int status;
>
> dprintk("--> %s inode %p layout range: %Zd@%llu\n", __func__, inode,
> - (size_t)(npages * PAGE_SIZE),
> - (u64)((u64)idx_start * PAGE_SIZE));
> + (size_t)(npages * PAGE_CACHE_SIZE),
> + (u64)((u64)idx_start << PAGE_CACHE_SHIFT));
>
> if (!pnfs_enabled_sb(nfss))
> return;
> +
> + /* COMMIT indicates the whole file with offset = count = 0
> + * whereas layout segments indicate whole file with offset = 0,
> + * count = NFS4_MAX_UINT64.
> + */
> + count = (size_t)npages * PAGE_CACHE_SIZE;
> + start = (loff_t)idx_start << PAGE_CACHE_SHIFT;
> + if (start == 0 && count == 0)
> + count = NFS4_MAX_UINT64;
> +
> status = pnfs_update_layout(inode, nfs_page->wb_context,
> - (size_t)npages * PAGE_SIZE,
> - (loff_t)idx_start * PAGE_SIZE,
> + count,
> + start,
> IOMODE_RW,
> NULL);
> dprintk("%s virt update status %d\n", __func__, status);
> @@ -2057,6 +2069,7 @@ pnfs_commit(struct nfs_write_data *data, int sync)
> struct nfs_page *first, *last, *p;
> int npages;
> enum pnfs_try_status trypnfs;
> + u64 count;
>
> dprintk("%s: Begin\n", __func__);
>
> @@ -2069,6 +2082,15 @@ pnfs_commit(struct nfs_write_data *data, int sync)
> last = p;
> npages++;
> }
> + /* COMMIT indicates the whole file with offset = count = 0
> + * whereas layout segments indicate whole file with offset = 0,
> + * count = NFS4_MAX_UINT64.
> + */
> + count = ((npages - 1) << PAGE_CACHE_SHIFT) + first->wb_bytes +
> + (first != last) ? last->wb_bytes : 0;
> + if (first->wb_offset == 0 && count == 0)
> + count = NFS4_MAX_UINT64;
> +
> /* FIXME: we really ought to keep the layout segment that we used
> to write the page around for committing it and never ask for a
> new one. If it was recalled we better commit the data first
> @@ -2076,9 +2098,7 @@ pnfs_commit(struct nfs_write_data *data, int sync)
> either with a new layout or to the MDS */
> result = pnfs_update_layout(data->inode,
> NULL,
> - ((npages - 1) << PAGE_CACHE_SHIFT) +
> - first->wb_bytes +
> - (first != last) ? last->wb_bytes : 0,
> + count,
> first->wb_offset,
> IOMODE_RW,
> &lseg);
> diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
> index b06fde4..2f5dae4 100644
> --- a/fs/nfs/pnfs.h
> +++ b/fs/nfs/pnfs.h
> @@ -34,7 +34,7 @@ extern int pnfs4_proc_layoutreturn(struct nfs4_pnfs_layoutreturn *lrp);
> extern const nfs4_stateid zero_stateid;
>
> int pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
> - size_t count, loff_t pos, enum pnfs_iomode access_type,
> + u64 count, loff_t pos, enum pnfs_iomode access_type,
> struct pnfs_layout_segment **lsegpp);
>
> int _pnfs_return_layout(struct inode *, struct nfs4_pnfs_layout_segment *,
next prev parent reply other threads:[~2009-11-03 6:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1256217343-6991-1-git-send-email-andros@netapp.com>
2009-10-22 13:15 ` [PATCH 1/2] pnfs: fix-multiple-free-slot-calls andros
2009-10-22 13:15 ` [PATCH 2/2] pnfs: fix pnfs_commit update_layout range andros
2009-11-03 6:24 ` Benny Halevy [this message]
2009-11-03 6:24 ` [pnfs] [PATCH 1/2] pnfs: fix-multiple-free-slot-calls Benny Halevy
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=4AEFCC92.4050002@panasas.com \
--to=bhalevy@panasas.com \
--cc=andros@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=pnfs@linux-nfs.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