2015-04-09 15:05:12

by Peng Tao

[permalink] [raw]
Subject: [PATCH v2 1/2] nfs: fix DIO good bytes calculation

For direct read that has IO size larger than rsize, we'll split
it into several READ requests and nfs_direct_good_bytes() would
count completed bytes incorrectly by eating last zero count reply.

Fix it by handling mirror and non-mirror cases differently such that
we only count mirrored writes differently.

This fixes 5fadeb47("nfs: count DIO good bytes correctly with mirroring").

Reported-by: Jean Spector <[email protected]>
Cc: <[email protected]> # v3.19+
Signed-off-by: Peng Tao <[email protected]>
---
fs/nfs/direct.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index e907c8c..5e451a7 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -131,20 +131,25 @@ nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr)

WARN_ON_ONCE(hdr->pgio_mirror_idx >= dreq->mirror_count);

- count = dreq->mirrors[hdr->pgio_mirror_idx].count;
- if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) {
- count = hdr->io_start + hdr->good_bytes - dreq->io_start;
- dreq->mirrors[hdr->pgio_mirror_idx].count = count;
- }
-
- /* update the dreq->count by finding the minimum agreed count from all
- * mirrors */
- count = dreq->mirrors[0].count;
+ if (dreq->mirror_count == 1) {
+ dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes;
+ dreq->count += hdr->good_bytes;
+ } else {
+ /* mirrored writes */
+ count = dreq->mirrors[hdr->pgio_mirror_idx].count;
+ if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) {
+ count = hdr->io_start + hdr->good_bytes - dreq->io_start;
+ dreq->mirrors[hdr->pgio_mirror_idx].count = count;
+ }
+ /* update the dreq->count by finding the minimum agreed count from all
+ * mirrors */
+ count = dreq->mirrors[0].count;

- for (i = 1; i < dreq->mirror_count; i++)
- count = min(count, dreq->mirrors[i].count);
+ for (i = 1; i < dreq->mirror_count; i++)
+ count = min(count, dreq->mirrors[i].count);

- dreq->count = count;
+ dreq->count = count;
+ }
}

/*
--
1.9.1



2015-04-09 15:05:18

by Peng Tao

[permalink] [raw]
Subject: [PATCH v2 2/2] nfs: remove WARN_ON_ONCE from nfs_direct_good_bytes

For flexfiles driver, we might choose to read from mirror index other
than 0 while mirror_count is always 1 for read.

Reported-by: Jean Spector <[email protected]>
Cc: <[email protected]> # v3.19+
Cc: Weston Andros Adamson <[email protected]>
Signed-off-by: Peng Tao <[email protected]>
---
This is updated due to conflict with patch 1/2.
fs/nfs/direct.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 5e451a7..ab21ef1 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -129,8 +129,6 @@ nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr)
int i;
ssize_t count;

- WARN_ON_ONCE(hdr->pgio_mirror_idx >= dreq->mirror_count);
-
if (dreq->mirror_count == 1) {
dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes;
dreq->count += hdr->good_bytes;
--
1.9.1


2015-04-21 12:18:01

by Josh Boyer

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] nfs: fix DIO good bytes calculation

On Thu, Apr 9, 2015 at 11:02 AM, Peng Tao <[email protected]> wrote:
> For direct read that has IO size larger than rsize, we'll split
> it into several READ requests and nfs_direct_good_bytes() would
> count completed bytes incorrectly by eating last zero count reply.
>
> Fix it by handling mirror and non-mirror cases differently such that
> we only count mirrored writes differently.
>
> This fixes 5fadeb47("nfs: count DIO good bytes correctly with mirroring").
>
> Reported-by: Jean Spector <[email protected]>
> Cc: <[email protected]> # v3.19+
> Signed-off-by: Peng Tao <[email protected]>

This one (and 2/2 in the series) have been setting here with no
comments for a while now. Are these going to get picked up for 4.1?
We have a couple of bug reports against 3.19 that these should fix, so
I'm curious if they're headed in-tree.

josh

> ---
> fs/nfs/direct.c | 29 +++++++++++++++++------------
> 1 file changed, 17 insertions(+), 12 deletions(-)
>
> diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
> index e907c8c..5e451a7 100644
> --- a/fs/nfs/direct.c
> +++ b/fs/nfs/direct.c
> @@ -131,20 +131,25 @@ nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr)
>
> WARN_ON_ONCE(hdr->pgio_mirror_idx >= dreq->mirror_count);
>
> - count = dreq->mirrors[hdr->pgio_mirror_idx].count;
> - if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) {
> - count = hdr->io_start + hdr->good_bytes - dreq->io_start;
> - dreq->mirrors[hdr->pgio_mirror_idx].count = count;
> - }
> -
> - /* update the dreq->count by finding the minimum agreed count from all
> - * mirrors */
> - count = dreq->mirrors[0].count;
> + if (dreq->mirror_count == 1) {
> + dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes;
> + dreq->count += hdr->good_bytes;
> + } else {
> + /* mirrored writes */
> + count = dreq->mirrors[hdr->pgio_mirror_idx].count;
> + if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) {
> + count = hdr->io_start + hdr->good_bytes - dreq->io_start;
> + dreq->mirrors[hdr->pgio_mirror_idx].count = count;
> + }
> + /* update the dreq->count by finding the minimum agreed count from all
> + * mirrors */
> + count = dreq->mirrors[0].count;
>
> - for (i = 1; i < dreq->mirror_count; i++)
> - count = min(count, dreq->mirrors[i].count);
> + for (i = 1; i < dreq->mirror_count; i++)
> + count = min(count, dreq->mirrors[i].count);
>
> - dreq->count = count;
> + dreq->count = count;
> + }
> }
>
> /*
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html