Added swap support
This commit is contained in:
parent
4822424518
commit
dd8b7f2b10
@ -1889,17 +1889,8 @@ static struct swap_info_struct *alloc_swap_info(void)
|
|||||||
static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
|
static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
/* On Chromium OS, we only support zram swap devices. */
|
|
||||||
if (S_ISBLK(inode->i_mode)) {
|
if (S_ISBLK(inode->i_mode)) {
|
||||||
char name[BDEVNAME_SIZE];
|
|
||||||
p->bdev = bdgrab(I_BDEV(inode));
|
p->bdev = bdgrab(I_BDEV(inode));
|
||||||
bdevname(p->bdev, name);
|
|
||||||
if (strncmp(name, "zram", strlen("zram")) &&
|
|
||||||
strncmp(name, "ram", strlen("ram"))) {
|
|
||||||
bdput(p->bdev);
|
|
||||||
p->bdev = NULL;
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
error = blkdev_get(p->bdev,
|
error = blkdev_get(p->bdev,
|
||||||
FMODE_READ | FMODE_WRITE | FMODE_EXCL,
|
FMODE_READ | FMODE_WRITE | FMODE_EXCL,
|
||||||
sys_swapon);
|
sys_swapon);
|
||||||
@ -1912,13 +1903,11 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
|
|||||||
if (error < 0)
|
if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
p->flags |= SWP_BLKDEV;
|
p->flags |= SWP_BLKDEV;
|
||||||
#if 0
|
|
||||||
} else if (S_ISREG(inode->i_mode)) {
|
} else if (S_ISREG(inode->i_mode)) {
|
||||||
p->bdev = inode->i_sb->s_bdev;
|
p->bdev = inode->i_sb->s_bdev;
|
||||||
mutex_lock(&inode->i_mutex);
|
mutex_lock(&inode->i_mutex);
|
||||||
if (IS_SWAPFILE(inode))
|
if (IS_SWAPFILE(inode))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
#endif
|
|
||||||
} else
|
} else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user