提交 107c161b 编写于 作者: N Nitin Gupta 提交者: Greg Kroah-Hartman

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: NNitin Gupta <ngupta@vflare.org>
Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
Acked-by: NNigel Cunningham <nigel@tuxonice.net>
Acked-by: NPekka Enberg <penberg@cs.helsinki.fi>
Reviewed-by: NMinchan Kim <minchan.kim@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 b3a27d05
TODO:
- Add support for swap notifiers
Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
Nitin Gupta <ngupta@vflare.org>
......@@ -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 @@ static int ramzswap_ioctl(struct block_device *bdev, fmode_t mode,
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册