linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niu Yawei <yawei.niu@gmail.com>
To: adityakali@google.com, tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, yawei.niu@intel.com
Subject: [PATCH] tune2fs: update i_size in ext2fs_file_write()
Date: Thu, 12 Sep 2013 22:21:50 +0800	[thread overview]
Message-ID: <5231CDFE.8050206@gmail.com> (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.

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

             reply	other threads:[~2013-09-12 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 14:21 Niu Yawei [this message]
2013-10-08  3:30 ` [PATCH] tune2fs: update i_size in ext2fs_file_write() Niu Yawei
2013-10-08 15:45   ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5231CDFE.8050206@gmail.com \
    --to=yawei.niu@gmail.com \
    --cc=adityakali@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yawei.niu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).