Message ID | AANLkTi=gqurEsoMZv+10Np4duOKq4kZf77mTgu6BfkSC@mail.gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
--- fs/btrfs/file.c 2011-03-05 07:34:43.025131607 -0600 +++ /usr/src/linux/fs/btrfs/file.c 2011-03-05 07:41:45.001260294 -0600 @@ -1023,8 +1023,20 @@ copied = btrfs_copy_from_user(pos, num_pages, write_bytes, pages, &i); - dirty_pages = (copied + offset + PAGE_CACHE_SIZE - 1) >> - PAGE_CACHE_SHIFT; + + /* + * if we have trouble faulting in the pages, fall + * back to one page at a time + */ + if (copied < write_bytes) + nrptrs = 1; + + if (copied == 0) + dirty_pages = 0; + else + dirty_pages = (copied + offset + + PAGE_CACHE_SIZE - 1) >> + PAGE_CACHE_SHIFT; if (num_pages > dirty_pages) { if (copied > 0)