|
@@ -1974,12 +1974,14 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
|
|
|
goto bad_swap;
|
|
|
}
|
|
|
|
|
|
- if (blk_queue_nonrot(bdev_get_queue(p->bdev))) {
|
|
|
- p->flags |= SWP_SOLIDSTATE;
|
|
|
- p->cluster_next = 1 + (random32() % p->highest_bit);
|
|
|
+ if (p->bdev) {
|
|
|
+ if (blk_queue_nonrot(bdev_get_queue(p->bdev))) {
|
|
|
+ p->flags |= SWP_SOLIDSTATE;
|
|
|
+ p->cluster_next = 1 + (random32() % p->highest_bit);
|
|
|
+ }
|
|
|
+ if (discard_swap(p) == 0)
|
|
|
+ p->flags |= SWP_DISCARDABLE;
|
|
|
}
|
|
|
- if (discard_swap(p) == 0)
|
|
|
- p->flags |= SWP_DISCARDABLE;
|
|
|
|
|
|
mutex_lock(&swapon_mutex);
|
|
|
spin_lock(&swap_lock);
|