nfs/blocklayout: make sure making a aligned read request
Only treat write goes up to the inode size as aligned request, because it always write PAGE_CACHE_SIZE, but read a dynamic size. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
parent
1425075e72
commit
f35592a974
|
@ -743,7 +743,7 @@ bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh)
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_aligned_req(struct nfs_pageio_descriptor *pgio,
|
is_aligned_req(struct nfs_pageio_descriptor *pgio,
|
||||||
struct nfs_page *req, unsigned int alignment)
|
struct nfs_page *req, unsigned int alignment, bool is_write)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Always accept buffered writes, higher layers take care of the
|
* Always accept buffered writes, higher layers take care of the
|
||||||
|
@ -758,7 +758,8 @@ is_aligned_req(struct nfs_pageio_descriptor *pgio,
|
||||||
if (IS_ALIGNED(req->wb_bytes, alignment))
|
if (IS_ALIGNED(req->wb_bytes, alignment))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (req_offset(req) + req->wb_bytes == i_size_read(pgio->pg_inode)) {
|
if (is_write &&
|
||||||
|
(req_offset(req) + req->wb_bytes == i_size_read(pgio->pg_inode))) {
|
||||||
/*
|
/*
|
||||||
* If the write goes up to the inode size, just write
|
* If the write goes up to the inode size, just write
|
||||||
* the full page. Data past the inode size is
|
* the full page. Data past the inode size is
|
||||||
|
@ -775,7 +776,7 @@ is_aligned_req(struct nfs_pageio_descriptor *pgio,
|
||||||
static void
|
static void
|
||||||
bl_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
|
bl_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
|
||||||
{
|
{
|
||||||
if (!is_aligned_req(pgio, req, SECTOR_SIZE)) {
|
if (!is_aligned_req(pgio, req, SECTOR_SIZE, false)) {
|
||||||
nfs_pageio_reset_read_mds(pgio);
|
nfs_pageio_reset_read_mds(pgio);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -791,7 +792,7 @@ static size_t
|
||||||
bl_pg_test_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
|
bl_pg_test_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
|
||||||
struct nfs_page *req)
|
struct nfs_page *req)
|
||||||
{
|
{
|
||||||
if (!is_aligned_req(pgio, req, SECTOR_SIZE))
|
if (!is_aligned_req(pgio, req, SECTOR_SIZE, false))
|
||||||
return 0;
|
return 0;
|
||||||
return pnfs_generic_pg_test(pgio, prev, req);
|
return pnfs_generic_pg_test(pgio, prev, req);
|
||||||
}
|
}
|
||||||
|
@ -824,7 +825,7 @@ bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
|
||||||
{
|
{
|
||||||
u64 wb_size;
|
u64 wb_size;
|
||||||
|
|
||||||
if (!is_aligned_req(pgio, req, PAGE_SIZE)) {
|
if (!is_aligned_req(pgio, req, PAGE_SIZE, true)) {
|
||||||
nfs_pageio_reset_write_mds(pgio);
|
nfs_pageio_reset_write_mds(pgio);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -846,7 +847,7 @@ static size_t
|
||||||
bl_pg_test_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
|
bl_pg_test_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
|
||||||
struct nfs_page *req)
|
struct nfs_page *req)
|
||||||
{
|
{
|
||||||
if (!is_aligned_req(pgio, req, PAGE_SIZE))
|
if (!is_aligned_req(pgio, req, PAGE_SIZE, true))
|
||||||
return 0;
|
return 0;
|
||||||
return pnfs_generic_pg_test(pgio, prev, req);
|
return pnfs_generic_pg_test(pgio, prev, req);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue