Skip to content

Commit

Permalink
cifs: use find_get_pages_range_tag()
Browse files Browse the repository at this point in the history
wdata_alloc_and_fillpages() needlessly iterates calls to
find_get_pages_tag().  Also it wants only pages from given range.  Make
it use find_get_pages_range_tag().

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Jan Kara <[email protected]>
Suggested-by: Daniel Jordan <[email protected]>
Reviewed-by: Daniel Jordan <[email protected]>
Cc: Steve French <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jankara authored and torvalds committed Nov 16, 2017
1 parent aef6e41 commit 9c19a9c
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1963,32 +1963,15 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping,
pgoff_t end, pgoff_t *index,
unsigned int *found_pages)
{
unsigned int nr_pages;
struct page **pages;
struct cifs_writedata *wdata;

wdata = cifs_writedata_alloc((unsigned int)tofind,
cifs_writev_complete);
if (!wdata)
return NULL;

/*
* find_get_pages_tag seems to return a max of 256 on each
* iteration, so we must call it several times in order to
* fill the array or the wsize is effectively limited to
* 256 * PAGE_SIZE.
*/
*found_pages = 0;
pages = wdata->pages;
do {
nr_pages = find_get_pages_tag(mapping, index,
PAGECACHE_TAG_DIRTY, tofind,
pages);
*found_pages += nr_pages;
tofind -= nr_pages;
pages += nr_pages;
} while (nr_pages && tofind && *index <= end);

*found_pages = find_get_pages_range_tag(mapping, index, end,
PAGECACHE_TAG_DIRTY, tofind, wdata->pages);
return wdata;
}

Expand Down

0 comments on commit 9c19a9c

Please sign in to comment.