The patch titled sys_swapon: separate swap_info allocation has been added to the -mm tree. Its filename is sys_swapon-separate-swap_info-allocation.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: separate swap_info allocation From: Cesar Eduardo Barros <cesarb@xxxxxxxxxx> Move the swap_info allocation to its own function. Only code movement, no functional changes. Signed-off-by: Cesar Eduardo Barros <cesarb@xxxxxxxxxx> Tested-by: Eric B Munson <emunson@xxxxxxxxx> Acked-by: Eric B Munson <emunson@xxxxxxxxx> Reviewed-by: Pekka Enberg <penberg@xxxxxxxxxx> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/swapfile.c | 57 +++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff -puN mm/swapfile.c~sys_swapon-separate-swap_info-allocation mm/swapfile.c --- a/mm/swapfile.c~sys_swapon-separate-swap_info-allocation +++ a/mm/swapfile.c @@ -1844,33 +1844,15 @@ static int __init max_swapfiles_check(vo late_initcall(max_swapfiles_check); #endif -SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) +static struct swap_info_struct *alloc_swap_info(void) { struct swap_info_struct *p; - char *name = NULL; - struct block_device *bdev = NULL; - struct file *swap_file = NULL; - struct address_space *mapping; unsigned int type; - int i, prev; int error; - union swap_header *swap_header; - unsigned int nr_good_pages; - int nr_extents = 0; - sector_t span; - unsigned long maxpages; - unsigned long swapfilepages; - unsigned char *swap_map = NULL; - struct page *page = NULL; - struct inode *inode = NULL; - int did_down = 0; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) - return -ENOMEM; + return ERR_PTR(-ENOMEM); spin_lock(&swap_lock); for (type = 0; type < nr_swapfiles; type++) { @@ -1906,6 +1888,41 @@ SYSCALL_DEFINE2(swapon, const char __use p->next = -1; spin_unlock(&swap_lock); + return p; + +out: + return ERR_PTR(error); +} + +SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) +{ + struct swap_info_struct *p; + char *name = NULL; + struct block_device *bdev = NULL; + struct file *swap_file = NULL; + struct address_space *mapping; + int i, prev; + int error; + union swap_header *swap_header; + unsigned int nr_good_pages; + int nr_extents = 0; + sector_t span; + unsigned long maxpages; + unsigned long swapfilepages; + unsigned char *swap_map = NULL; + struct page *page = NULL; + struct inode *inode = NULL; + int did_down = 0; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + + p = alloc_swap_info(); + if (IS_ERR(p)) { + error = PTR_ERR(p); + goto out; + } + name = getname(specialfile); error = PTR_ERR(name); if (IS_ERR(name)) { _ Patches currently in -mm which might be from cesarb@xxxxxxxxxx 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 -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html