diff mbox series

[v3,5/9] loop: Remove figure_loop_size()

Message ID 20200427074222.65369-6-maco@android.com (mailing list archive)
State New, archived
Headers show
Series Add a new LOOP_SET_FD_AND_STATUS ioctl | expand

Commit Message

Martijn Coenen April 27, 2020, 7:42 a.m. UTC
This function was now only used by loop_set_capacity(), and updating the
offset and sizelimit is no longer necessary in that case. Just open code
the remaining code in the caller instead.

Signed-off-by: Martijn Coenen <maco@android.com>
---
 drivers/block/loop.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

Comments

Christoph Hellwig April 27, 2020, 2:56 p.m. UTC | #1
On Mon, Apr 27, 2020 at 09:42:18AM +0200, Martijn Coenen wrote:
> This function was now only used by loop_set_capacity(), and updating the
> offset and sizelimit is no longer necessary in that case. Just open code
> the remaining code in the caller instead.

Removing the now unused size update logic better fits into the previous
patch I think.  Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index d0f17ee1e29b..d9a1a7e8b192 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -259,26 +259,6 @@  static void loop_set_size(struct loop_device *lo, loff_t size)
 	set_capacity_revalidate_and_notify(lo->lo_disk, size, false);
 }
 
-static int
-figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit)
-{
-	int err;
-	loff_t size = get_size(offset, sizelimit, lo->lo_backing_file);
-
-	err = loop_validate_size(size);
-	if (err)
-		return err;
-
-	if (lo->lo_offset != offset)
-		lo->lo_offset = offset;
-	if (lo->lo_sizelimit != sizelimit)
-		lo->lo_sizelimit = sizelimit;
-
-	loop_set_size(lo, size);
-
-	return 0;
-}
-
 static inline int
 lo_do_transfer(struct loop_device *lo, int cmd,
 	       struct page *rpage, unsigned roffs,
@@ -1566,10 +1546,21 @@  loop_get_status64(struct loop_device *lo, struct loop_info64 __user *arg) {
 
 static int loop_set_capacity(struct loop_device *lo)
 {
+	int err;
+	loff_t size;
+
 	if (unlikely(lo->lo_state != Lo_bound))
 		return -ENXIO;
 
-	return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit);
+	size = get_loop_size(lo, lo->lo_backing_file);
+
+	err = loop_validate_size(size);
+	if (err)
+		return err;
+
+	loop_set_size(lo, size);
+
+	return 0;
 }
 
 static int loop_set_dio(struct loop_device *lo, unsigned long arg)