* [PATCH] Btrfs: Fix page count calculation
@ 2011-01-18 5:34 Yan, Zheng
2011-01-19 1:15 ` Chris Mason
0 siblings, 1 reply; 2+ messages in thread
From: Yan, Zheng @ 2011-01-18 5:34 UTC (permalink / raw)
To: linux-btrfs
take offset of start position into account when calculating page count.
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 66836d8..ef94e46 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -970,8 +970,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
size_t write_bytes = min(iov_iter_count(&i),
nrptrs * (size_t)PAGE_CACHE_SIZE -
offset);
- size_t num_pages = (write_bytes + PAGE_CACHE_SIZE - 1) >>
- PAGE_CACHE_SHIFT;
+ size_t num_pages = (write_bytes + offset +
+ PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
WARN_ON(num_pages > nrptrs);
memset(pages, 0, sizeof(struct page *) * nrptrs);
@@ -1001,8 +1001,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
copied = btrfs_copy_from_user(pos, num_pages,
write_bytes, pages, &i);
- dirty_pages = (copied + PAGE_CACHE_SIZE - 1) >>
- PAGE_CACHE_SHIFT;
+ dirty_pages = (copied + offset + PAGE_CACHE_SIZE - 1) >>
+ PAGE_CACHE_SHIFT;
if (num_pages > dirty_pages) {
if (copied > 0)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: Fix page count calculation
2011-01-18 5:34 [PATCH] Btrfs: Fix page count calculation Yan, Zheng
@ 2011-01-19 1:15 ` Chris Mason
0 siblings, 0 replies; 2+ messages in thread
From: Chris Mason @ 2011-01-19 1:15 UTC (permalink / raw)
To: Yan, Zheng; +Cc: linux-btrfs
Excerpts from Yan, Zheng's message of 2011-01-18 00:34:40 -0500:
> take offset of start position into account when calculating page count.
Thanks Yan, do you have a test case that exposes this? I'd like to add
it to xfsqa if it makes sense.
-chris
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-19 1:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-18 5:34 [PATCH] Btrfs: Fix page count calculation Yan, Zheng
2011-01-19 1:15 ` Chris Mason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).