Skip to content

Commit

Permalink
Btrfs: Fix page count calculation
Browse files Browse the repository at this point in the history
take offset of start position into account when calculating page count.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Yan, Zheng authored and chrismason-xx committed Feb 7, 2011
1 parent 8e4eef7 commit 3a90983
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/btrfs/file.c
Expand Up @@ -991,8 +991,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);
Expand Down Expand Up @@ -1022,8 +1022,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)
Expand Down

0 comments on commit 3a90983

Please sign in to comment.