Re: [RFC PATCH 02/02] swapon: add "cluster-discard" support

From: KOSAKI Motohiro
Date: Mon May 20 2013 - 21:07:53 EST


> +.B "\-c, \-\-cluster\-discard"
> +Swapping will discard clusters of swap pages in between freeing them
> +and re-writing to them, if the swap device supports that. This option
> +also implies the
> +.I \-d, \-\-discard
> +swapon flag.

I'm not sure this is good idea. Why can't we make these flags orthogonal?


> /* If true, don't complain if the device/file doesn't exist */
> static int ifexists;
> @@ -570,8 +574,11 @@ static int do_swapon(const char *orig_special, int prio,
> << SWAP_FLAG_PRIO_SHIFT);
> }
> #endif
> - if (fl_discard)
> + if (fl_discard) {
> flags |= SWAP_FLAG_DISCARD;
> + if (fl_discard > 1)
> + flags |= SWAP_FLAG_DISCARD_CLUSTER;

This is not enough, IMHO. When running this code on old kernel, swapon() return EINVAL.
At that time, we should fall back swapon(0x10000).

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/