mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-30 11:04:25 +00:00
Btrfs: Fix page count calculation
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>
This commit is contained in:
parent
8e4eef7a60
commit
3a90983dbd
1 changed files with 4 additions and 4 deletions
|
@ -991,8 +991,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
|
||||||
size_t write_bytes = min(iov_iter_count(&i),
|
size_t write_bytes = min(iov_iter_count(&i),
|
||||||
nrptrs * (size_t)PAGE_CACHE_SIZE -
|
nrptrs * (size_t)PAGE_CACHE_SIZE -
|
||||||
offset);
|
offset);
|
||||||
size_t num_pages = (write_bytes + PAGE_CACHE_SIZE - 1) >>
|
size_t num_pages = (write_bytes + offset +
|
||||||
PAGE_CACHE_SHIFT;
|
PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
|
||||||
|
|
||||||
WARN_ON(num_pages > nrptrs);
|
WARN_ON(num_pages > nrptrs);
|
||||||
memset(pages, 0, sizeof(struct page *) * nrptrs);
|
memset(pages, 0, sizeof(struct page *) * nrptrs);
|
||||||
|
@ -1022,8 +1022,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
|
||||||
|
|
||||||
copied = btrfs_copy_from_user(pos, num_pages,
|
copied = btrfs_copy_from_user(pos, num_pages,
|
||||||
write_bytes, pages, &i);
|
write_bytes, pages, &i);
|
||||||
dirty_pages = (copied + PAGE_CACHE_SIZE - 1) >>
|
dirty_pages = (copied + offset + PAGE_CACHE_SIZE - 1) >>
|
||||||
PAGE_CACHE_SHIFT;
|
PAGE_CACHE_SHIFT;
|
||||||
|
|
||||||
if (num_pages > dirty_pages) {
|
if (num_pages > dirty_pages) {
|
||||||
if (copied > 0)
|
if (copied > 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue