From mboxrd@z Thu Jan 1 00:00:00 1970 From: akpm@linux-foundation.org Subject: + sys_swapon-do-only-cleanup-in-the-cleanup-blocks.patch added to -mm tree Date: Mon, 07 Mar 2011 14:10:08 -0800 Message-ID: <201103072210.p27MA8RW030010@imap1.linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:54372 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754608Ab1CGWNw (ORCPT ); Mon, 7 Mar 2011 17:13:52 -0500 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: mm-commits@vger.kernel.org Cc: cesarb@cesarb.net, emunson@mgebm.net, hughd@google.com, kamezawa.hiroyu@jp.fujitsu.com The patch titled sys_swapon: do only cleanup in the cleanup blocks has been added to the -mm tree. Its filename is sys_swapon-do-only-cleanup-in-the-cleanup-blocks.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: sys_swapon: do only cleanup in the cleanup blocks From: Cesar Eduardo Barros The only way error is 0 in the cleanup blocks is when the function is returning successfully. In this case, the cleanup blocks were setting S_SWAPFILE in the S_ISREG case. But this is not a cleanup. Move the setting of S_SWAPFILE to just before the "goto out;" to make this more clear. At this point, we do not need to test for inode because it will never be NULL. Signed-off-by: Cesar Eduardo Barros Tested-by: Eric B Munson Acked-by: Eric B Munson Reviewed-by: KAMEZAWA Hiroyuki Cc: Hugh Dickins Signed-off-by: Andrew Morton --- mm/swapfile.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff -puN mm/swapfile.c~sys_swapon-do-only-cleanup-in-the-cleanup-blocks mm/swapfile.c --- a/mm/swapfile.c~sys_swapon-do-only-cleanup-in-the-cleanup-blocks +++ a/mm/swapfile.c @@ -2136,6 +2136,8 @@ SYSCALL_DEFINE2(swapon, const char __use atomic_inc(&proc_poll_event); wake_up_interruptible(&proc_poll_wait); + if (S_ISREG(inode->i_mode)) + inode->i_flags |= S_SWAPFILE; error = 0; goto out; bad_swap: @@ -2160,11 +2162,8 @@ out: } if (name) putname(name); - if (inode && S_ISREG(inode->i_mode)) { - if (!error) - inode->i_flags |= S_SWAPFILE; + if (inode && S_ISREG(inode->i_mode)) mutex_unlock(&inode->i_mutex); - } return error; } _ Patches currently in -mm which might be from cesarb@cesarb.net are sys_swapon-use-vzalloc-instead-of-vmalloc-memset.patch sys_swapon-remove-changelog-from-function-comment.patch sys_swapon-do-not-depend-on-type-after-allocation.patch sys_swapon-separate-swap_info-allocation.patch sys_swapon-simplify-error-return-from-swap_info-allocation.patch sys_swapon-simplify-error-flow-in-alloc_swap_info.patch sys_swapon-remove-initial-value-of-name-variable.patch sys_swapon-move-setting-of-error-nearer-use.patch sys_swapon-remove-did_down-variable.patch sys_swapon-remove-bdev-variable.patch sys_swapon-do-only-cleanup-in-the-cleanup-blocks.patch sys_swapon-use-a-single-error-label.patch sys_swapon-separate-bdev-claim-and-inode-lock.patch sys_swapon-simplify-error-flow-in-claim_swapfile.patch sys_swapon-move-setting-of-swapfilepages-near-use.patch sys_swapon-separate-parsing-of-swapfile-header.patch sys_swapon-simplify-error-flow-in-read_swap_header.patch sys_swapon-call-swap_cgroup_swapon-earlier.patch sys_swapon-separate-parsing-of-bad-blocks-and-extents.patch sys_swapon-simplify-error-flow-in-setup_swap_map_and_extents.patch sys_swapon-remove-nr_good_pages-variable.patch sys_swapon-move-printk-outside-lock.patch sys_swapoff-change-order-to-match-sys_swapon.patch sys_swapon-separate-final-enabling-of-the-swapfile.patch