mm, swap: don't use VMA based swap readahead if HDD is used as swap
[sfrench/cifs-2.6.git] / mm / swapfile.c
index 42eff9e4e9721bbd952d132f591fcfd7d2427193..4f8b3e08a5476e867366f1bf91f74751bb7fc8e7 100644 (file)
@@ -96,6 +96,8 @@ static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
 /* Activity counter to indicate that a swapon or swapoff has occurred */
 static atomic_t proc_poll_event = ATOMIC_INIT(0);
 
+atomic_t nr_rotate_swap = ATOMIC_INIT(0);
+
 static inline unsigned char swap_count(unsigned char ent)
 {
        return ent & ~SWAP_HAS_CACHE;   /* may include SWAP_HAS_CONT flag */
@@ -2569,6 +2571,9 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
        if (p->flags & SWP_CONTINUED)
                free_swap_count_continuations(p);
 
+       if (!p->bdev || !blk_queue_nonrot(bdev_get_queue(p->bdev)))
+               atomic_dec(&nr_rotate_swap);
+
        mutex_lock(&swapon_mutex);
        spin_lock(&swap_lock);
        spin_lock(&p->lock);
@@ -3145,7 +3150,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
                        cluster = per_cpu_ptr(p->percpu_cluster, cpu);
                        cluster_set_null(&cluster->index);
                }
-       }
+       } else
+               atomic_inc(&nr_rotate_swap);
 
        error = swap_cgroup_swapon(p->type, maxpages);
        if (error)