Commit bb3247a3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

PM: rewrite is_hibernate_resume_dev to not require an inode

Just check the dev_t to help simplifying the code.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent ef16e1d9
...@@ -1885,7 +1885,7 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -1885,7 +1885,7 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (bdev_read_only(I_BDEV(bd_inode))) if (bdev_read_only(I_BDEV(bd_inode)))
return -EPERM; return -EPERM;
if (IS_SWAPFILE(bd_inode) && !is_hibernate_resume_dev(bd_inode)) if (IS_SWAPFILE(bd_inode) && !is_hibernate_resume_dev(bd_inode->i_rdev))
return -ETXTBSY; return -ETXTBSY;
if (!iov_iter_count(from)) if (!iov_iter_count(from))
......
...@@ -473,9 +473,9 @@ static inline int hibernate_quiet_exec(int (*func)(void *data), void *data) { ...@@ -473,9 +473,9 @@ static inline int hibernate_quiet_exec(int (*func)(void *data), void *data) {
#endif /* CONFIG_HIBERNATION */ #endif /* CONFIG_HIBERNATION */
#ifdef CONFIG_HIBERNATION_SNAPSHOT_DEV #ifdef CONFIG_HIBERNATION_SNAPSHOT_DEV
int is_hibernate_resume_dev(const struct inode *); int is_hibernate_resume_dev(dev_t dev);
#else #else
static inline int is_hibernate_resume_dev(const struct inode *i) { return 0; } static inline int is_hibernate_resume_dev(dev_t dev) { return 0; }
#endif #endif
/* Hibernation and suspend events */ /* Hibernation and suspend events */
......
...@@ -35,12 +35,12 @@ static struct snapshot_data { ...@@ -35,12 +35,12 @@ static struct snapshot_data {
bool ready; bool ready;
bool platform_support; bool platform_support;
bool free_bitmaps; bool free_bitmaps;
struct inode *bd_inode; dev_t dev;
} snapshot_state; } snapshot_state;
int is_hibernate_resume_dev(const struct inode *bd_inode) int is_hibernate_resume_dev(dev_t dev)
{ {
return hibernation_available() && snapshot_state.bd_inode == bd_inode; return hibernation_available() && snapshot_state.dev == dev;
} }
static int snapshot_open(struct inode *inode, struct file *filp) static int snapshot_open(struct inode *inode, struct file *filp)
...@@ -101,7 +101,7 @@ static int snapshot_open(struct inode *inode, struct file *filp) ...@@ -101,7 +101,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
data->frozen = false; data->frozen = false;
data->ready = false; data->ready = false;
data->platform_support = false; data->platform_support = false;
data->bd_inode = NULL; data->dev = 0;
Unlock: Unlock:
unlock_system_sleep(); unlock_system_sleep();
...@@ -117,7 +117,7 @@ static int snapshot_release(struct inode *inode, struct file *filp) ...@@ -117,7 +117,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)
swsusp_free(); swsusp_free();
data = filp->private_data; data = filp->private_data;
data->bd_inode = NULL; data->dev = 0;
free_all_swap_pages(data->swap); free_all_swap_pages(data->swap);
if (data->frozen) { if (data->frozen) {
pm_restore_gfp_mask(); pm_restore_gfp_mask();
...@@ -245,7 +245,7 @@ static int snapshot_set_swap_area(struct snapshot_data *data, ...@@ -245,7 +245,7 @@ static int snapshot_set_swap_area(struct snapshot_data *data,
if (data->swap < 0) if (data->swap < 0)
return -ENODEV; return -ENODEV;
data->bd_inode = bdev->bd_inode; data->dev = bdev->bd_dev;
bdput(bdev); bdput(bdev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment