All of lore.kernel.org
 help / color / mirror / Atom feed
From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: linux-btrfs@vger.kernel.org
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: [RFC PATCH 25/31] btrfs: remove all page related functions
Date: Sun, 13 Jun 2021 08:39:53 -0500	[thread overview]
Message-ID: <adc05e1b047f3adcd83cb0b8defec4aabc55ae49.1623567940.git.rgoldwyn@suse.com> (raw)
In-Reply-To: <cover.1623567940.git.rgoldwyn@suse.com>

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Cleanup after switching to iomap writes. Remove all page handling
functions.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/file.c | 156 ------------------------------------------------
 1 file changed, 156 deletions(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 6c6e3343bf37..b3e48bfd75df 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -394,79 +394,6 @@ int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info)
 	return 0;
 }
 
-/* simple helper to fault in pages and copy.  This should go away
- * and be replaced with calls into generic code.
- */
-static noinline int btrfs_copy_from_user(loff_t pos, size_t write_bytes,
-					 struct page **prepared_pages,
-					 struct iov_iter *i)
-{
-	size_t copied = 0;
-	size_t total_copied = 0;
-	int pg = 0;
-	int offset = offset_in_page(pos);
-
-	while (write_bytes > 0) {
-		size_t count = min_t(size_t,
-				     PAGE_SIZE - offset, write_bytes);
-		struct page *page = prepared_pages[pg];
-		/*
-		 * Copy data from userspace to the current page
-		 */
-		copied = iov_iter_copy_from_user_atomic(page, i, offset, count);
-
-		/* Flush processor's dcache for this page */
-		flush_dcache_page(page);
-
-		/*
-		 * if we get a partial write, we can end up with
-		 * partially up to date pages.  These add
-		 * a lot of complexity, so make sure they don't
-		 * happen by forcing this copy to be retried.
-		 *
-		 * The rest of the btrfs_file_write code will fall
-		 * back to page at a time copies after we return 0.
-		 */
-		if (!PageUptodate(page) && copied < count)
-			copied = 0;
-
-		iov_iter_advance(i, copied);
-		write_bytes -= copied;
-		total_copied += copied;
-
-		/* Return to btrfs_file_write_iter to fault page */
-		if (unlikely(copied == 0))
-			break;
-
-		if (copied < PAGE_SIZE - offset) {
-			offset += copied;
-		} else {
-			pg++;
-			offset = 0;
-		}
-	}
-	return total_copied;
-}
-
-/*
- * unlocks pages after btrfs_file_write is done with them
- */
-static void btrfs_drop_pages(struct page **pages, size_t num_pages)
-{
-	size_t i;
-	for (i = 0; i < num_pages; i++) {
-		/* page checked is some magic around finding pages that
-		 * have been modified without going through btrfs_set_page_dirty
-		 * clear it here. There should be no need to mark the pages
-		 * accessed as prepare_pages should have marked them accessed
-		 * in prepare_pages via find_or_create_page()
-		 */
-		ClearPageChecked(pages[i]);
-		unlock_page(pages[i]);
-		put_page(pages[i]);
-	}
-}
-
 static void btrfs_page_done(struct inode *inode, loff_t pos,
 		unsigned int copied, struct page *page,
 		struct iomap *iomap)
@@ -1346,89 +1273,6 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
 	return ret;
 }
 
-/*
- * on error we return an unlocked page and the error value
- * on success we return a locked page and 0
- */
-static int prepare_uptodate_page(struct inode *inode,
-				 struct page *page, u64 pos)
-{
-	int ret = 0;
-
-	if ((pos & (PAGE_SIZE - 1)) && !PageUptodate(page)) {
-		ret = btrfs_readpage(NULL, page);
-		if (ret)
-			return ret;
-		lock_page(page);
-		if (!PageUptodate(page)) {
-			unlock_page(page);
-			return -EIO;
-		}
-		if (page->mapping != inode->i_mapping) {
-			unlock_page(page);
-			return -EAGAIN;
-		}
-	}
-	return 0;
-}
-
-/*
- * this just gets pages into the page cache and locks them down.
- */
-static noinline int prepare_pages(struct inode *inode, struct page **pages,
-				  size_t num_pages, loff_t pos,
-				  size_t write_bytes)
-{
-	int i;
-	unsigned long index = pos >> PAGE_SHIFT;
-	gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
-	int err = 0;
-	int faili;
-
-	for (i = 0; i < num_pages; i++) {
-again:
-		pages[i] = find_or_create_page(inode->i_mapping, index + i,
-					       mask | __GFP_WRITE);
-		if (!pages[i]) {
-			faili = i - 1;
-			err = -ENOMEM;
-			goto fail;
-		}
-
-		err = set_page_extent_mapped(pages[i]);
-		if (err < 0) {
-			faili = i;
-			goto fail;
-		}
-
-		if (i == 0)
-			err = prepare_uptodate_page(inode, pages[i], pos);
-		if (!err && i == num_pages - 1)
-			err = prepare_uptodate_page(inode, pages[i],
-						    pos + write_bytes);
-		if (err) {
-			put_page(pages[i]);
-			if (err == -EAGAIN) {
-				err = 0;
-				goto again;
-			}
-			faili = i - 1;
-			goto fail;
-		}
-		wait_on_page_writeback(pages[i]);
-	}
-
-	return 0;
-fail:
-	while (faili >= 0) {
-		unlock_page(pages[faili]);
-		put_page(pages[faili]);
-		faili--;
-	}
-	return err;
-
-}
-
 static int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
 			   size_t *write_bytes, bool nowait)
 {
-- 
2.31.1


  parent reply	other threads:[~2021-06-13 13:41 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13 13:39 [RFC PATCH 00/31] btrfs buffered iomap support Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 01/31] iomap: Check if blocksize == PAGE_SIZE in to_iomap_page() Goldwyn Rodrigues
2021-06-15 14:17   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 02/31] iomap: Add submit_io to writepage_ops Goldwyn Rodrigues
2021-06-15 14:15   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 03/31] iomap: Export iomap_writepage_end_bio() Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 04/31] iomap: Introduce iomap_readpage_ops Goldwyn Rodrigues
2021-06-15 14:44   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 05/31] btrfs: writepage() lock extent before pages Goldwyn Rodrigues
2021-06-15 15:47   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 06/31] btrfs: lock extents while truncating Goldwyn Rodrigues
2021-06-16  6:42   ` Nikolay Borisov
2021-06-16 13:13   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 07/31] btrfs: write() perform extent locks before locking page Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 08/31] btrfs: btrfs_em_to_iomap () to convert em to iomap Goldwyn Rodrigues
2021-06-16  6:49   ` Nikolay Borisov
2021-06-16  6:51   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 09/31] btrfs: Don't process pages if locked_page is NULL Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 10/31] btrfs: Add btrfs_map_blocks to for iomap_writeback_ops Goldwyn Rodrigues
2021-06-16 14:15   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 11/31] btrfs: Use submit_io to submit btrfs writeback bios Goldwyn Rodrigues
2021-06-16 14:26   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 12/31] btrfs: endio sequence for writepage Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 13/31] btrfs: do not checksum for free space inode Goldwyn Rodrigues
2021-06-16 14:46   ` Nikolay Borisov
2021-06-13 13:39 ` [RFC PATCH 14/31] btrfs: end EXTENT_MAP_INLINE writeback early Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 15/31] btrfs: Switch to iomap_writepages() Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 16/31] btrfs: remove force_page_uptodate Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 17/31] btrfs: Introduce btrfs_iomap Goldwyn Rodrigues
2021-06-16 20:02   ` David Sterba
2021-06-13 13:39 ` [RFC PATCH 18/31] btrfs: Add btrfs_iomap_release() Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 19/31] btrfs: Add reservation information to btrfs_iomap Goldwyn Rodrigues
2021-06-16 20:03   ` David Sterba
2021-06-13 13:39 ` [RFC PATCH 20/31] btrfs: Carve out btrfs_buffered_iomap_begin() from write path Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 21/31] btrfs: Carve out btrfs_buffered_iomap_end from the " Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 22/31] btrfs: Set extents delalloc in iomap_end Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 23/31] btrfs: define iomap_page_ops Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 24/31] btrfs: Switch to iomap_file_buffered_write() Goldwyn Rodrigues
2021-06-13 13:39 ` Goldwyn Rodrigues [this message]
2021-06-13 13:39 ` [RFC PATCH 26/31] btrfs: use srcmap for read-before-write cases Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 27/31] btrfs: Rename end_bio_extent_readpage to btrfs_readpage_endio Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 28/31] btrfs: iomap_begin() for buffered read Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 29/31] btrfs: Use iomap_readpage_ops to allocate and submit bio Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 30/31] btrfs: Do not call btrfs_io_bio_free_csum() if BTRFS_INODE_NODATASUM is not set Goldwyn Rodrigues
2021-06-13 13:39 ` [RFC PATCH 31/31] btrfs: Switch to iomap_readpage() and iomap_readahead() Goldwyn Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adc05e1b047f3adcd83cb0b8defec4aabc55ae49.1623567940.git.rgoldwyn@suse.com \
    --to=rgoldwyn@suse.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=rgoldwyn@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.