linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Fang <fangwei1@huawei.com>
To: <tigran@aivazian.fsnet.co.uk>
Cc: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Wei Fang <fangwei1@huawei.com>
Subject: [PATCH] bfs: fix i_blocks accounting
Date: Mon, 2 Nov 2015 17:03:35 +0800	[thread overview]
Message-ID: <1446455015-26888-1-git-send-email-fangwei1@huawei.com> (raw)

Update inode->i_blocks if succeed to get block, otherwise we'll
get wrong number of blocks.

Signed-off-by: Wei Fang <fangwei1@huawei.com>
---
 fs/bfs/file.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index 97f1b51..f89abdb 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -108,6 +108,7 @@ static int bfs_get_block(struct inode *inode, sector_t block,
 		map_bh(bh_result, sb, phys);
 		info->si_freeb -= phys - bi->i_eblock;
 		info->si_lf_eblk = bi->i_eblock = phys;
+		inode->i_blocks = block + 1;
 		mark_inode_dirty(inode);
 		err = 0;
 		goto out;
@@ -141,7 +142,8 @@ static int bfs_get_block(struct inode *inode, sector_t block,
 	 * This assumes nothing can write the inode back while we are here
 	 * and thus update inode->i_blocks! (XXX)
 	 */
-	info->si_freeb -= bi->i_eblock - bi->i_sblock + 1 - inode->i_blocks;
+	info->si_freeb -= block + 1 - inode->i_blocks;
+	inode->i_blocks = block + 1;
 	mark_inode_dirty(inode);
 	map_bh(bh_result, sb, phys);
 out:
-- 
1.7.1


                 reply	other threads:[~2015-11-02  9:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1446455015-26888-1-git-send-email-fangwei1@huawei.com \
    --to=fangwei1@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tigran@aivazian.fsnet.co.uk \
    /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).