| Kernel v2.4.12-ac6 /mm/shmem.c |
|---|
 2.4.12-ac6
 mm
 shmem.c
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla/mm/shmem.c linux.ac/mm/shmem.c
--- linux.vanilla/mm/shmem.c Thu Oct 11 13:52:17 2001
+++ linux.ac/mm/shmem.c Sun Oct 21 18:54:37 2001
@@ -47,10 +47,15 @@
LIST_HEAD (shmem_inodes);
static spinlock_t shmem_ilock = SPIN_LOCK_UNLOCKED;
-atomic_t shmem_nrpages = ATOMIC_INIT(0); /* Not used right now */
+atomic_t shmem_nrpages = ATOMIC_INIT(0);
#define BLOCKS_PER_PAGE (PAGE_CACHE_SIZE/512)
+static void shmem_removepage(struct page *page)
+{
+ atomic_dec(&shmem_nrpages);
+}
+
/*
* shmem_recalc_inode - recalculate the size of an inode
*
@@ -387,6 +392,7 @@
return 0;
found:
add_to_page_cache(page, info->inode->i_mapping, offset + idx);
+ atomic_inc(&shmem_nrpages);
SetPageDirty(page);
SetPageUptodate(page);
UnlockPage(page);
@@ -465,6 +471,7 @@
* Add page back to page cache, unref swap, try again.
*/
add_to_page_cache_locked(page, mapping, index);
+ atomic_inc(&shmem_nrpages);
spin_unlock(&info->lock);
swap_free(swap);
goto getswap;
@@ -589,6 +596,7 @@
}
/* We have the page */
+ atomic_inc(&shmem_nrpages);
SetPageUptodate(page);
if (info->locked)
page_cache_get(page);
@@ -1237,45 +1245,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)
@@ -1344,6 +1361,7 @@
static struct address_space_operations shmem_aops = {
+ removepage: shmem_removepage,
writepage: shmem_writepage,
};
|