From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jaegeuk Kim Subject: Re: [PATCH 2/2 v2] f2fs: add f2fs_balance_fs in several interfaces Date: Fri, 11 Jan 2013 15:27:25 +0900 Message-ID: <1357885645.3527.5.camel@kjgkr> References: <1357773978-29167-1-git-send-email-jaegeuk.kim@samsung.com> <1357773978-29167-2-git-send-email-jaegeuk.kim@samsung.com> Reply-To: jaegeuk.kim@samsung.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-S+v0LEQYxDLK8KgEtOmR" Cc: linux-f2fs-devel@lists.sourceforge.net To: linux-fsdevel@vger.kernel.org Return-path: Received: from mailout4.samsung.com ([203.254.224.34]:57832 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751339Ab3AKG11 (ORCPT ); Fri, 11 Jan 2013 01:27:27 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGG00E1179QM1O0@mailout4.samsung.com> for linux-fsdevel@vger.kernel.org; Fri, 11 Jan 2013 15:27:26 +0900 (KST) Received: from [12.52.126.105] by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MGG00EDF79Q9F40@mmp2.samsung.com> for linux-fsdevel@vger.kernel.org; Fri, 11 Jan 2013 15:27:26 +0900 (KST) In-reply-to: <1357773978-29167-2-git-send-email-jaegeuk.kim@samsung.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --=-S+v0LEQYxDLK8KgEtOmR Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Change log from v1: o add the f2fs_write_inode case =46rom 7d82db83165dbac8c3f6d47b73c84f38e3996e30 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 11 Jan 2013 13:10:49 +0900 Subject: [PATCH] f2fs: add f2fs_balance_fs in several interfaces The f2fs_balance_fs() is to check the number of free sections and decide whether it needs to conduct cleaning or not. If there are not enough free sections, the cleaning job should be started. In order to control an amount of free sections even under high utilization, f2fs should call f2fs_balance_fs at all the VFS interfaces that are able to produce dirty pages. This patch adds the function calls in the missing interfaces as follows. 1. f2fs_setxattr() The f2fs_setxattr() produces dirty node pages so that we should call f2fs_balance_fs() either likewise doing in other VFS interfaces such as f2fs_lookup(), f2fs_mkdir(), and so on. 2. f2fs_sync_file() We should guarantee serving free sections for syncing metadata during fsync. Previously, there is no space check before triggering checkpoint and sync_node_pages. Therefore, if a bunch of fsync calls are triggered under 100% of FS utilization, f2fs is able to be faced with no free sections, resulting in BUG_ON(). 3. f2fs_sync_fs() Before calling write_checkpoint(), we should guarantee that there are minimum free sections. 4. f2fs_write_inode() f2fs_write_inode() is also able to produce dirty node pages. Signed-off-by: Jaegeuk Kim --- fs/f2fs/file.c | 3 +++ fs/f2fs/inode.c | 3 +++ fs/f2fs/super.c | 2 ++ fs/f2fs/xattr.c | 2 ++ 4 files changed, 10 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 88593c5..7354c2d 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -137,6 +137,9 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) if (ret) return ret; =20 + /* guarantee free sections for fsync */ + f2fs_balance_fs(sbi); + mutex_lock(&inode->i_mutex); =20 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index bf20b4d..7942417 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -217,6 +217,9 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) inode->i_ino =3D=3D F2FS_META_INO(sbi)) return 0; =20 + if (wbc) + f2fs_balance_fs(sbi); + node_page =3D get_node_page(sbi, inode->i_ino); if (IS_ERR(node_page)) return PTR_ERR(node_page); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index afa7ef0..0f2b2eb 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -137,6 +137,8 @@ int f2fs_sync_fs(struct super_block *sb, int sync) =20 if (sync) write_checkpoint(sbi, false, false); + else + f2fs_balance_fs(sbi); =20 return 0; } diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 940136a..8038c04 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -318,6 +318,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, if (name_len > 255 || value_len > MAX_VALUE_LEN) return -ERANGE; =20 + f2fs_balance_fs(sbi); + mutex_lock_op(sbi, NODE_NEW); if (!fi->i_xattr_nid) { /* Allocate new attribute block */ --=20 1.8.0.1.250.gb7973fb --=20 Jaegeuk Kim Samsung --=-S+v0LEQYxDLK8KgEtOmR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJQ77DNAAoJEEAUqH6CSFDSnDYQAIjQbmMy1EPEhi4GKH7SQkPU GC2MmFvoc9UG2WkO2QGD8fb6q+QX5tkTTVpVxGUBA0S2094x46QrAmxnkJf+972e RDY8nZC2dv4caJeVwTGxjjL9yVfiieakDl+mxat3bLH1PkfMwGWlTqPMgEb7fj4b lMT12DiINCa+4e/4tXE2daG6w4YfFeRY9cbaX7XA0VxY2/WHZXaC/qf9368oYVt2 oQyGl2gyXfiUw4IJvYQRl8jl/DJ+fozffT1KhX7ZJPxrMK9LAbq6M0y7kJpweVwn xRDQAY5My6DtvQCzLOkRlNJEAvcgYBP3wfKLWmlJksaFFXH3ndTRJBJ0PjuSjyVp eM9VSJ0vFCBDkzNmgQNYrJTmdjuJRcRFkb8WF52Q3g3UTcw3mzI/N4M0KQD7JW2/ 2ZSd3BHsAV0/yTCAMGCssl6WQWoabLmvnF8NC0yQd5JKGf5Ex1PJ7w2YG3KfE0zk 63PkSNeoLBQkK7A6KKt/mYNvDPYb20hUQl83VfI557+qAzuZnQdHkGHJ76h4b9+0 xV0XIgp8uMG6frGC+a91Oz00IHuDMhZ5hJvSTf+saTPY8a+4aymhTzEBNO4VpbfE 0f50pHeNPNA098IfJuiR6rhA6HRvFF6vXC6Lwc7bOn24m73u+WE50cxCYJDzBvV4 hg3pYnPpTTzQ2S1lOuha =cO0N -----END PGP SIGNATURE----- --=-S+v0LEQYxDLK8KgEtOmR--