Skip to contentSkip to conversation

fs: make block fiemap mapping length at least blocksize long

PATCH In review Josef Bacik 3 participants 3 messages Dec 8, 2010 – Feb 1, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: make block fiemap mapping length at least blocksize long

Some filesystems don't deal well with being asked to map less than blocksize blocks (GFS2 for example). Since we are always mapping at least blocksize sections anyway, just make sure len is at least as big as a blocksize so we don't trip up any filesystems. Thanks,

---
 fs/ioctl.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
fs/ioctl.c +7 -0
index d6cc164..6b53c24 100644
@@ -273,6 +273,13 @@ int __generic_block_fiemap(struct inode *inode,
 		len = isize;
 	}
 
+	/*
+	 * Some filesystems can't deal with being asked to map less than
+	 * blocksize, so make sure our len is at least block length.
+	 */
+	if (logical_to_blk(inode, len) == 0)
+		len = blk_to_logical(inode, 1);
+
 	start_blk = logical_to_blk(inode, start);
 	last_blk = logical_to_blk(inode, start + len - 1);
 
Signature · 1 line
1.6.6.1
#1 lore raw

Hi,

Is there any reason this cannot be sent to Linus now?

Steve.

Quoted 28 lines · Josef Bacik

Some filesystems don't deal well with being asked to map less than blocksize blocks (GFS2 for example). Since we are always mapping at least blocksize sections anyway, just make sure len is at least as big as a blocksize so we don't trip up any filesystems. Thanks,

---
 fs/ioctl.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
fs/ioctl.c +7 -0
index d6cc164..6b53c24 100644
@@ -273,6 +273,13 @@ int __generic_block_fiemap(struct inode *inode,
 		len = isize;
 	}
 
+	/*
+	 * Some filesystems can't deal with being asked to map less than
+	 * blocksize, so make sure our len is at least block length.
+	 */
+	if (logical_to_blk(inode, len) == 0)
+		len = blk_to_logical(inode, 1);
+
 	start_blk = logical_to_blk(inode, start);
 	last_blk = logical_to_blk(inode, start + len - 1);
 
#2 lore raw
Quoted 19 lines · On Tue, 01 Feb 2011 11:46:50 +0000 Steven Whitehouse <[email protected]>…
Quoted 18 lines · Josef Bacik

Some filesystems don't deal well with being asked to map less than blocksize blocks (GFS2 for example). Since we are always mapping at least blocksize sections anyway, just make sure len is at least as big as a blocksize so we don't trip up any filesystems. Thanks,

---
 fs/ioctl.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
fs/ioctl.c +0 -0
index d6cc164..6b53c24 100644
@@ -273,6 +273,13 @@ int __generic_block_fiemap(struct inode *inode,
 		len = isize;
 	}
 
Quoted 10 lines

fs/ioctl.c int __generic_block_fiemap(struct inode *inode, · line 285

Quoted 10 lines
fs/ioctl.c +7 -0
+	/*
+	 * Some filesystems can't deal with being asked to map less than
+	 * blocksize, so make sure our len is at least block length.
+	 */
+	if (logical_to_blk(inode, len) == 0)
+		len = blk_to_logical(inode, 1);
+
 	start_blk = logical_to_blk(inode, start);
 	last_blk = logical_to_blk(inode, start + len - 1);
 

(top-posting repaired)

Quoted 4 lines

Hi,

Is there any reason this cannot be sent to Linus now?

I sent it to viro a couple of weeks back and it was ignored. I don't know why this happens :(