Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Kernel v2.4.13 /mm/shmem.c

Filename:/mm/shmem.c
Lines Added:34
Lines Deleted:27
Also changed in: (Previous) 2.4.13-pre6  2.4.13-pre5  2.4.13-pre4  2.4.13-pre3  2.4.12-ac6  2.4.12-ac4 
(Following) 2.4.13-ac1  2.4.13-ac2  2.4.13-ac3  2.4.13-ac4  2.4.13-ac5  2.4.13-ac6 

Location
[  2.4.13
  [  mm
     o  shmem.c

Patch

diff -u --recursive --new-file v2.4.12/linux/mm/shmem.c linux/mm/shmem.c
--- v2.4.12/linux/mm/shmem.c   Thu Oct 11 08:02:26 2001
+++ linux/mm/shmem.c   Wed Oct 17 14:19:20 2001
@@ -386,10 +386,10 @@
    spin_unlock (&info->lock);
    return 0;
 found:
+   delete_from_swap_cache(page);
    add_to_page_cache(page, info->inode->i_mapping, offset + idx);
    SetPageDirty(page);
    SetPageUptodate(page);
-   UnlockPage(page);
    info->swapped--;
    spin_unlock(&info->lock);
    return 1;
@@ -531,10 +531,8 @@
       if (!page) {
          swp_entry_t swap = *entry;
          spin_unlock (&info->lock);
-         lock_kernel();
          swapin_readahead(*entry);
          page = read_swap_cache_async(*entry);
-         unlock_kernel();
          if (!page) {
             if (entry->val != swap.val)
                goto repeat;
@@ -1237,45 +1235,54 @@
 
 static int shmem_parse_options(char *options, int *mode, unsigned long * blocks, unsigned long *inodes)
 {
-   char *this_char, *value;
+   char *this_char, *value, *rest;
 
    this_char = NULL;
    if ( options )
       this_char = strtok(options,",");
    for ( ; this_char; this_char = strtok(NULL,",")) {
-      if ((value = strchr(this_char,'=')) != NULL)
+      if ((value = strchr(this_char,'=')) != NULL) {
          *value++ = 0;
+      } else {
+         printk(KERN_ERR 
+             "shmem_parse_options: No value for option '%s'\n", 
+             this_char);
+         return 1;
+      }
+
       if (!strcmp(this_char,"size")) {
          unsigned long long size;
-         if (!value || !*value || !blocks)
-            return 1;
-         size = memparse(value,&value);
-         if (*value)
-            return 1;
+         size = memparse(value,&rest);
+         if (*rest)
+            goto bad_val;
          *blocks = size >> PAGE_CACHE_SHIFT;
       } else if (!strcmp(this_char,"nr_blocks")) {
-         if (!value || !*value || !blocks)
-            return 1;
-         *blocks = memparse(value,&value);
-         if (*value)
-            return 1;
+         *blocks = memparse(value,&rest);
+         if (*rest)
+            goto bad_val;
       } else if (!strcmp(this_char,"nr_inodes")) {
-         if (!value || !*value || !inodes)
-            return 1;
-         *inodes = memparse(value,&value);
-         if (*value)
-            return 1;
+         *inodes = memparse(value,&rest);
+         if (*rest)
+            goto bad_val;
       } else if (!strcmp(this_char,"mode")) {
-         if (!value || !*value || !mode)
-            return 1;
-         *mode = simple_strtoul(value,&value,8);
-         if (*value)
-            return 1;
-      }
-      else
+         if (!mode)
+            continue;
+         *mode = simple_strtoul(value,&rest,8);
+         if (*rest)
+            goto bad_val;
+      } else {
+         printk(KERN_ERR "shmem_parse_options: Bad option %s\n",
+                this_char);
          return 1;
+      }
    }
    return 0;
+
+bad_val:
+   printk(KERN_ERR "shmem_parse_options: Bad value '%s' for option '%s'\n", 
+          value, this_char);
+   return 1;
+
 }
 
 static int shmem_remount_fs (struct super_block *sb, int *flags, char *data)


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.