diff options
author | Nitin Gupta <ngupta@vflare.org> | 2010-05-17 11:02:44 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-18 15:07:52 -0700 |
commit | 107c161b7ddeeb7da43509cc6b29211885ccd9af (patch) | |
tree | 1857a45cb9fad39eb17c1e26766084ee3d034533 /drivers/staging | |
parent | b3a27d0529c6e5206f1b60f60263e3ecfd0d77cb (diff) |
Staging: ramzswap: Handler for swap slot free callback
Install handler for swap_slot_free_notify callback which is called
when a swap slot is no longer used. This handler immediately frees
memory allocated corresponding to the given swap slot.
Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Nigel Cunningham <nigel@tuxonice.net>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/ramzswap/TODO | 5 | ||||
-rw-r--r-- | drivers/staging/ramzswap/ramzswap_drv.c | 22 |
2 files changed, 13 insertions, 14 deletions
diff --git a/drivers/staging/ramzswap/TODO b/drivers/staging/ramzswap/TODO deleted file mode 100644 index 8d64e28fac0..00000000000 --- a/drivers/staging/ramzswap/TODO +++ /dev/null @@ -1,5 +0,0 @@ -TODO: - - Add support for swap notifiers - -Please send patches to Greg Kroah-Hartman <greg@kroah.com> and -Nitin Gupta <ngupta@vflare.org> diff --git a/drivers/staging/ramzswap/ramzswap_drv.c b/drivers/staging/ramzswap/ramzswap_drv.c index 167f8d17a80..d14bf9129e3 100644 --- a/drivers/staging/ramzswap/ramzswap_drv.c +++ b/drivers/staging/ramzswap/ramzswap_drv.c @@ -335,14 +335,6 @@ static int ramzswap_write(struct ramzswap *rzs, struct bio *bio) src = rzs->compress_buffer; - /* - * System swaps to same sector again when the stored page - * is no longer referenced by any process. So, its now safe - * to free the memory that was allocated for this page. - */ - if (rzs->table[index].page || rzs_test_flag(rzs, index, RZS_ZERO)) - ramzswap_free_page(rzs, index); - mutex_lock(&rzs->lock); user_mem = kmap_atomic(page, KM_USER0); @@ -690,9 +682,21 @@ out: return ret; } +void ramzswap_slot_free_notify(struct block_device *bdev, unsigned long index) +{ + struct ramzswap *rzs; + + rzs = bdev->bd_disk->private_data; + ramzswap_free_page(rzs, index); + rzs_stat64_inc(rzs, &rzs->stats.notify_free); + + return; +} + static struct block_device_operations ramzswap_devops = { .ioctl = ramzswap_ioctl, - .owner = THIS_MODULE, + .swap_slot_free_notify = ramzswap_slot_free_notify, + .owner = THIS_MODULE }; static int create_device(struct ramzswap *rzs, int device_id) |