Skip to contentSkip to conversation

gfs2: Clarify gfs2_block_map

PATCH New Andreas Gruenbacher 2 participants 2 messages Sep 21, 2017 – Sep 25, 2017 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Clarify gfs2_block_map

Add a comment about the logical block size for directories. Rename "bsize" in gfs2_block_map to "factor". Fix a typo in the description of metaptr1.

---
 fs/gfs2/bmap.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
fs/gfs2/bmap.c +10 -4
index 3dd0cceefa43..8830e2903a34 100644
@@ -248,7 +248,7 @@ static inline unsigned int metapath_branch_start(const struct metapath *mp)
 }
 
 /**
- * metaptr1 - Return the first possible metadata pointer in a metaath buffer
+ * metaptr1 - Return the first possible metadata pointer in a metapath buffer
  * @height: The metadata height (0 = dinode)
  * @mp: The metapath
  */
@@ -659,7 +659,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 {
 	struct gfs2_inode *ip = GFS2_I(inode);
 	struct gfs2_sbd *sdp = GFS2_SB(inode);
-	unsigned int bsize = sdp->sd_sb.sb_bsize;
+	unsigned int factor = sdp->sd_sb.sb_bsize;
 	const size_t maxlen = bh_map->b_size >> inode->i_blkbits;
 	const u64 *arr = sdp->sd_heightsize;
 	__be64 *ptr;
@@ -679,8 +679,14 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 	clear_buffer_new(bh_map);
 	clear_buffer_boundary(bh_map);
 	trace_gfs2_bmap(ip, bh_map, lblock, create, 1);
+
+	/*
+	 * Directory data blocks have a struct gfs2_meta_header header, so the
+	 * remaining size is smaller than the filesystem block size.  Logical
+	 * block numbers for directories are in units of this remaining size!
+	 */
 	if (gfs2_is_dir(ip)) {
-		bsize = sdp->sd_jbsize;
+		factor = sdp->sd_jbsize;
 		arr = sdp->sd_jheightsize;
 	}
 
@@ -689,7 +695,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 		goto out;
 
 	height = ip->i_height;
-	size = (lblock + 1) * bsize;
+	size = (lblock + 1) * factor;
 	while (size > arr[height])
 		height++;
 	find_metapath(sdp, lblock, &mp, height);
Signature · 1 line
2.13.3
#1 lore raw

PATCH 1/1 gfs2: Clarify gfs2_block_map

----- Original Message -----

| Add a comment about the logical block size for directories.  Rename
| "bsize" in gfs2_block_map to "factor".  Fix a typo in the description of
| metaptr1.
| 
| Signed-off-by: Andreas Gruenbacher <[email protected]>
| ---
|  fs/gfs2/bmap.c | 14 ++++++++++----
|  1 file changed, 10 insertions(+), 4 deletions(-)

Hi,

Thanks. This is now pushed to the for-next branch of the linux-gfs2 tree:
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?h=for-next&id=3eaef9146f687e581ba563b24507ed620bf7f4c8

Regards,

Bob Peterson
Red Hat File Systems