From: shaobingqing <shaobingqing@bwstor.com.cn>
To: trond.myklebust@primarydata.com
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
shaobingqing <shaobingqing@bwstor.com.cn>
Subject: [PATCH] NFSv4.1: PNFS_BLOCK_NONE_DATA should be handle properly in bl_add_merge_extent?
Date: Mon, 20 Jan 2014 18:07:28 +0800 [thread overview]
Message-ID: <1390212448-21354-1-git-send-email-shaobingqing@bwstor.com.cn> (raw)
In-Reply-To: <n>
In the current code, extents would not delete from the bl_extents list when
lseg is removed from layout. Now one extent's lseg is deleted and its type
is PNFS_BLOCK_NONE_DATA, while a layoutget request get a extent with the same
range and its type is PNFS_BLOCK_NONE_DATA. In this situation the function
bl_add_merge_extent will return -EIO. Furthermore, the READ op which request
the layout will be execute in band. This perhaps not only degrade performance,
but also result in data unconsistency.
Signed-off-by: shaobingqing <shaobingqing@bwstor.com.cn>
---
fs/nfs/blocklayout/extents.c | 50 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/fs/nfs/blocklayout/extents.c b/fs/nfs/blocklayout/extents.c
index 9c3e117..7472b38 100644
--- a/fs/nfs/blocklayout/extents.c
+++ b/fs/nfs/blocklayout/extents.c
@@ -518,6 +518,34 @@ bl_add_merge_extent(struct pnfs_block_layout *bl,
__func__);
bl_put_extent(new);
return 0;
+ } else if (be->be_state ==
+ PNFS_BLOCK_NONE_DATA) {
+ splice = bl_alloc_extent();
+ if (!splice) {
+ bl_put_extent(new);
+ return -ENOMEM;
+ }
+ memcpy(splice, be,
+ sizeof(struct pnfs_block_extent));
+ splice->be_f_offset = end;
+ splice->be_length = be->be_f_offset
+ + be->be_length - end;
+ be->be_length = new->be_f_offset
+ - be->be_f_offset;
+ splice->be_v_offset = 0;
+
+ list_add(&new->be_node, &be->be_node);
+ if (be->be_length == 0) {
+ list_del(&be->be_node);
+ bl_put_extent(be);
+ }
+ if (splice->be_length != 0)
+ list_add(&splice->be_node,
+ &new->be_node);
+ else
+ bl_put_extent(splice);
+
+ return 0;
} else {
goto out_err;
}
@@ -533,6 +561,13 @@ bl_add_merge_extent(struct pnfs_block_layout *bl,
dprintk("%s: removing %p\n", __func__, be);
list_del(&be->be_node);
bl_put_extent(be);
+ } else if (be->be_state == PNFS_BLOCK_NONE_DATA) {
+ be->be_length = new->be_f_offset
+ - be->be_f_offset;
+ if (be->be_length == 0) {
+ list_del(&be->be_node);
+ bl_put_extent(be);
+ }
} else {
goto out_err;
}
@@ -544,6 +579,10 @@ bl_add_merge_extent(struct pnfs_block_layout *bl,
dprintk("%s: removing %p\n", __func__, be);
list_del(&be->be_node);
bl_put_extent(be);
+
+ } else if (be->be_state == PNFS_BLOCK_NONE_DATA) {
+ list_del(&be->be_node);
+ bl_put_extent(be);
} else {
goto out_err;
}
@@ -557,6 +596,17 @@ bl_add_merge_extent(struct pnfs_block_layout *bl,
dprintk("%s: removing %p\n", __func__, be);
list_del(&be->be_node);
bl_put_extent(be);
+
+ } else if (be->be_state == PNFS_BLOCK_NONE_DATA) {
+ be->be_length -= end - be->be_f_offset;
+ be->be_v_offset += end - be->be_f_offset;
+ be->be_f_offset = end;
+ list_add(&new->be_node, be->be_node.prev);
+ if (be->be_length == 0) {
+ list_del(&be->be_node);
+ bl_put_extent(be);
+ }
+ return 0;
} else {
goto out_err;
}
--
1.7.4.2
next reply other threads:[~2014-01-20 10:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 10:07 shaobingqing [this message]
2014-01-20 13:52 ` [PATCH] NFSv4.1: PNFS_BLOCK_NONE_DATA should be handle properly in bl_add_merge_extent? 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=1390212448-21354-1-git-send-email-shaobingqing@bwstor.com.cn \
--to=shaobingqing@bwstor.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.