Skip to contentSkip to conversation

tune2fs: update i_size in ext2fs_file_write()

PATCH Applied Niu Yawei 2 participants 3 messages Sep 12, 2013 – Oct 8, 2013

lore
Share & tools
lore

Niu Yawei

author
#0 lore raw

PATCH 1/1 tune2fs: update i_size in ext2fs_file_write()

ext2fs_file_write() needs to update i_size on successful write, otherwise, ext2fs_file_read() in same open/close cycle will not be able to read the just written data.

Which result in the the problem of quotacheck triggered on 'tune2fs -O quota' failed to write back multiple users/groups accounting information.

---
 lib/ext2fs/fileio.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
lib/ext2fs/fileio.c +0 -0
index 1f7002c..b1b5540 100644
@@ -304,6 +304,13 @@ errcode_t ext2fs_file_write(ext2_file_t file, const

void *buf,
ptr += c;
count += c;
nbytes -= c;
+
+ /* Update inode size */
+ if (EXT2_I_SIZE(&file->inode) < file->pos) {
+ retval = ext2fs_file_set_size2(file, file->pos);
+ if (retval)
+ goto fail;
+ }
}

fail:

Signature · 1 line
1.7.1
author
#1 lore raw

ext2fs_file_write() needs to update i_size on successful write, otherwise, ext2fs_file_read() in same open/close cycle will not be able to read the just written data.

This bug result in the the problem of quotacheck triggered on 'tune2fs -O quota' failed to write back multiple users/groups accounting information.

---
 lib/ext2fs/fileio.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
lib/ext2fs/fileio.c +0 -0
index 1f7002c..e395eb6 100644
@@ -307,6 +307,15 @@ errcode_t ext2fs_file_write(ext2_file_t file, const

void *buf,
}

fail:
+ /* Update inode size */
+ if (count != 0 && EXT2_I_SIZE(&file->inode) < file->pos) {
+ errcode_t rc;
+
+ rc = ext2fs_file_set_size2(file, file->pos);
+ if (retval == 0)
+ retval = rc;
+ }
+
if (written)
*written = count;
return retval;

Signature · 1 line
1.7.1
Quoted 33 lines

ext2fs_file_write() needs to update i_size on successful write, otherwise, ext2fs_file_read() in same open/close cycle will not be able to read the just written data.

Which result in the the problem of quotacheck triggered on 'tune2fs -O quota' failed to write back multiple users/groups accounting information.

---
 lib/ext2fs/fileio.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
lib/ext2fs/fileio.c +7 -0
index 1f7002c..b1b5540 100644
@@ -304,6 +304,13 @@ errcode_t ext2fs_file_write(ext2_file_t file, const
 void *buf,
 		ptr += c;
 		count += c;
 		nbytes -= c;
+
+		/* Update inode size */
+		if (EXT2_I_SIZE(&file->inode) < file->pos) {
+			retval = ext2fs_file_set_size2(file, file->pos);
+			if (retval)
+				goto fail;
+		}
 	}
 

fail:

#2 lore raw
Quoted 9 lines · Niu Yawei

ext2fs_file_write() needs to update i_size on successful write, otherwise, ext2fs_file_read() in same open/close cycle will not be able to read the just written data.

This bug result in the the problem of quotacheck triggered on 'tune2fs -O quota' failed to write back multiple users/groups accounting information.

Applied, thanks.

- Ted