diff mbox

tune2fs: update i_size in ext2fs_file_write()

Message ID 52537C42.9010808@gmail.com
State Accepted, archived
Headers show

Commit Message

Niu Yawei Oct. 8, 2013, 3:30 a.m. UTC
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.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
---
 lib/ext2fs/fileio.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

 	return retval;

Comments

Theodore Ts'o Oct. 8, 2013, 3:45 p.m. UTC | #1
On Tue, Oct 08, 2013 at 11:30:10AM +0800, Niu Yawei wrote:
> 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.
> 
> Signed-off-by: Niu Yawei <yawei.niu@intel.com>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index 1f7002c..e395eb6 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -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;