[patch-2.3.42] small optimization of swapon(2)/swapoff(2)

From: Tigran Aivazian (tigran@aivazian.fsnet.co.uk)
Date: Mon Feb 07 2000 - 14:28:20 EST


Hi Linus,

I hope this patch is so simple that it falls into the category of
"obviously correct" - it just reduces the length of holding kernel lock
and removes unnecessary initializations.

  http://www.ocston.org/~tigran/patches/swap-2.3.42.patch

Regards,
Tigran.

--- swapfile.c.0 Mon Feb 7 19:12:58 2000
+++ swapfile.c Mon Feb 7 19:13:02 2000
@@ -445,12 +445,12 @@
         struct swap_info_struct * p = NULL;
         struct dentry * dentry;
         int i, type, prev;
- int err = -EPERM;
+ int err;
         
- lock_kernel();
         if (!capable(CAP_SYS_ADMIN))
- goto out;
+ return -EPERM;
 
+ lock_kernel();
         dentry = namei(specialfile);
         err = PTR_ERR(dentry);
         if (IS_ERR(dentry))
@@ -587,7 +587,7 @@
         struct dentry * swap_dentry;
         unsigned int type;
         int i, j, prev;
- int error = -EPERM;
+ int error;
         static int least_priority = 0;
         union swap_header *swap_header = 0;
         int swap_header_version;
@@ -596,15 +596,17 @@
         int swapfilesize;
         struct block_device *bdev = NULL;
         
- lock_kernel();
         if (!capable(CAP_SYS_ADMIN))
- goto out;
+ return -EPERM;
+ lock_kernel();
         p = swap_info;
         for (type = 0 ; type < nr_swapfiles ; type++,p++)
                 if (!(p->flags & SWP_USED))
                         break;
- if (type >= MAX_SWAPFILES)
+ if (type >= MAX_SWAPFILES) {
+ err = -EPERM;
                 goto out;
+ }
         if (type >= nr_swapfiles)
                 nr_swapfiles = type+1;
         p->flags = SWP_USED;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Feb 07 2000 - 21:00:15 EST