Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b37392ea authored by Miao Xie's avatar Miao Xie Committed by Chris Mason
Browse files

Btrfs: cleanup unnecessary parameter and variant of prepare_pages()



- the caller has gotten the inode object, needn't pass the file object.
  And if so, we needn't define a inode pointer variant.
- the position should be aligned by the page size not sector size, so
  we also needn't pass the root object into prepare_pages().

Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent cc37bb04
Loading
Loading
Loading
Loading
+6 −8
Original line number Original line Diff line number Diff line
@@ -1239,22 +1239,20 @@ static int prepare_uptodate_page(struct page *page, u64 pos,
 * waits for data=ordered extents to finish before allowing the pages to be
 * waits for data=ordered extents to finish before allowing the pages to be
 * modified.
 * modified.
 */
 */
static noinline int prepare_pages(struct btrfs_root *root, struct file *file,
static noinline int prepare_pages(struct inode *inode, struct page **pages,
			 struct page **pages, size_t num_pages,
				  size_t num_pages, loff_t pos,
			 loff_t pos, unsigned long first_index,
				  size_t write_bytes, bool force_uptodate)
				  size_t write_bytes, bool force_uptodate)
{
{
	struct extent_state *cached_state = NULL;
	struct extent_state *cached_state = NULL;
	int i;
	int i;
	unsigned long index = pos >> PAGE_CACHE_SHIFT;
	unsigned long index = pos >> PAGE_CACHE_SHIFT;
	struct inode *inode = file_inode(file);
	gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
	gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
	int err = 0;
	int err = 0;
	int faili = 0;
	int faili = 0;
	u64 start_pos;
	u64 start_pos;
	u64 last_pos;
	u64 last_pos;


	start_pos = pos & ~((u64)root->sectorsize - 1);
	start_pos = pos & ~((u64)PAGE_CACHE_SIZE - 1);
	last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT;
	last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT;


again:
again:
@@ -1462,8 +1460,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
		 * pages we want, so we don't really need to worry about the
		 * pages we want, so we don't really need to worry about the
		 * contents of pages from loop to loop
		 * contents of pages from loop to loop
		 */
		 */
		ret = prepare_pages(root, file, pages, num_pages,
		ret = prepare_pages(inode, pages, num_pages,
				    pos, first_index, write_bytes,
				    pos, write_bytes,
				    force_page_uptodate);
				    force_page_uptodate);
		if (ret)
		if (ret)
			break;
			break;