* [PATCH] tune2fs: update i_size in ext2fs_file_write()
@ 2013-09-12 14:21 Niu Yawei
2013-10-08 3:30 ` Niu Yawei
0 siblings, 1 reply; 3+ messages in thread
From: Niu Yawei @ 2013-09-12 14:21 UTC (permalink / raw)
To: adityakali, tytso; +Cc: linux-ext4, yawei.niu
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.
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
---
lib/ext2fs/fileio.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index 1f7002c..b1b5540 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -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:
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tune2fs: update i_size in ext2fs_file_write()
2013-09-12 14:21 [PATCH] tune2fs: update i_size in ext2fs_file_write() Niu Yawei
@ 2013-10-08 3:30 ` Niu Yawei
2013-10-08 15:45 ` Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Niu Yawei @ 2013-10-08 3:30 UTC (permalink / raw)
To: adityakali, tytso; +Cc: linux-ext4, yawei.niu, andreas.dilger
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(-)
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;
return retval;
--
1.7.1
> 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.
>
> Signed-off-by: Niu Yawei <yawei.niu@intel.com>
> ---
> lib/ext2fs/fileio.c | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
> index 1f7002c..b1b5540 100644
> --- a/lib/ext2fs/fileio.c
> +++ b/lib/ext2fs/fileio.c
> @@ -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:
>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tune2fs: update i_size in ext2fs_file_write()
2013-10-08 3:30 ` Niu Yawei
@ 2013-10-08 15:45 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2013-10-08 15:45 UTC (permalink / raw)
To: Niu Yawei; +Cc: adityakali, linux-ext4, yawei.niu, andreas.dilger
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-08 15:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-12 14:21 [PATCH] tune2fs: update i_size in ext2fs_file_write() Niu Yawei
2013-10-08 3:30 ` Niu Yawei
2013-10-08 15:45 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).