Skip to contentSkip to conversation

GFS2: Get a block reservation before resizing a file

PATCH New Bob Peterson 2 participants 2 messages Feb 1, 2013 1 message not in the archive GFS2 file system

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 GFS2: Get a block reservation before resizing a file

In reply to a message not in the archive

Hi,

This patch allocates a block reservation structure before growing or shrinking a file. Without this structure, the grow or shink code can reference the bad pointer.

Regards,

Bob Peterson
Red Hat File Systems

---
 fs/gfs2/bmap.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/gfs2/bmap.c +4 -0
index d29d779..df686d1 100644
@@ -1288,6 +1288,10 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
 
 	inode_dio_wait(inode);
 
+	ret = gfs2_rs_alloc(GFS2_I(inode));
+	if (ret)
+		return ret;
+
 	oldsize = inode->i_size;
 	if (newsize >= oldsize)
 		return do_grow(inode, newsize);
#2 lore raw

PATCH 1/1 GFS2: Get a block reservation before resizing a file

Hi,

Now in the -nmw tree. Thanks,

Steve.

Quoted 32 lines · Bob Peterson

Hi,

This patch allocates a block reservation structure before growing or shrinking a file. Without this structure, the grow or shink code can reference the bad pointer.

Regards,

Bob Peterson
Red Hat File Systems

---
 fs/gfs2/bmap.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/gfs2/bmap.c +4 -0
index d29d779..df686d1 100644
@@ -1288,6 +1288,10 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
 
 	inode_dio_wait(inode);
 
+	ret = gfs2_rs_alloc(GFS2_I(inode));
+	if (ret)
+		return ret;
+
 	oldsize = inode->i_size;
 	if (newsize >= oldsize)
 		return do_grow(inode, newsize);