linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] loop device broken in 2.5.38
@ 2002-09-25 17:35 tytso
  2002-09-25 18:03 ` Andreas Dilger
  0 siblings, 1 reply; 3+ messages in thread
From: tytso @ 2002-09-25 17:35 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel


The loop device driver was broken in 2.5.38 when it was converted over
to use gendisk.  I discovered this while doing final regression testing
on the ext3 htree code.

The problem is that figure_loop_size() is setting the capacity of the
loop device in kilobytes (because that's what compute_loop_size()
returns), but set_capacity() expects the size in 512 byte sectors.

I've enclosed a patch which fixes the problem, as well as simplifying
the code by eliminating compute_loop_size(), since it is a static
function is only used once by figure_loop_size().

						- Ted

===== drivers/block/loop.c 1.57 vs edited =====
--- 1.57/drivers/block/loop.c	Sat Sep 21 02:08:48 2002
+++ edited/drivers/block/loop.c	Wed Sep 25 13:28:37 2002
@@ -157,18 +157,12 @@
 
 #define MAX_DISK_SIZE 1024*1024*1024
 
-static unsigned long
-compute_loop_size(struct loop_device *lo, struct dentry * lo_dentry)
-{
-	loff_t size = lo_dentry->d_inode->i_mapping->host->i_size;
-	return (size - lo->lo_offset) >> BLOCK_SIZE_BITS;
-}
-
 static void figure_loop_size(struct loop_device *lo)
 {
-	set_capacity(disks + lo->lo_number, compute_loop_size(lo,
-					lo->lo_backing_file->f_dentry));
-					
+	loff_t size = lo->lo_backing_file->f_dentry->d_inode->i_size;
+
+	set_capacity(disks + lo->lo_number,
+		     (size - lo->lo_offset) >> (BLOCK_SIZE_BITS-1));
 }
 
 static inline int lo_do_transfer(struct loop_device *lo, int cmd, char *rbuf,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-25 20:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-25 17:35 [PATCH] loop device broken in 2.5.38 tytso
2002-09-25 18:03 ` Andreas Dilger
2002-09-25 20:12   ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).