Skip to contentSkip to conversation

nfs: fix DIO good bytes calculation

PATCH Superseded Peng Tao 1 participant 2 messages Apr 8, 2015 – Apr 9, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peng Tao

author
#0 lore raw

PATCH 1/1 nfs: fix DIO good bytes calculation

When adding completed bytes, we should just use hdr->good_bytes. Otherwise if we send multiple requests for one direct IO (due to rsize/wsize limitation), we'll count completed bytes incorrectly.

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

---
 fs/nfs/direct.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/nfs/direct.c +2 -4
index e907c8c..645109e 100644
@@ -132,10 +132,8 @@ 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;
-	}
+	if (count + dreq->io_start < hdr->io_start + hdr->good_bytes)
+		dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes;
 
 	/* update the dreq->count by finding the minimum agreed count from all
 	 * mirrors */
Signature · 1 line
1.9.1
author
#1 lore raw
Quoted 18 lines · Peng Tao

When adding completed bytes, we should just use hdr->good_bytes. Otherwise if we send multiple requests for one direct IO (due to rsize/wsize limitation), we'll count completed bytes incorrectly.

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

---
 fs/nfs/direct.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/nfs/direct.c +0 -0
index e907c8c..645109e 100644

fs/nfs/direct.c nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr) · line 136

Quoted 9 lines
fs/nfs/direct.c +2 -4
@@ -132,10 +132,8 @@ 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;
-       }
+       if (count + dreq->io_start < hdr->io_start + hdr->good_bytes)
+               dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes;

oh, speaking too soon. This would actually fail concurrent DIO writers if split requests complete randomly. Please don't merge it! I'll send a updated version. sorry for the noise!

Thanks,
Tao