Re: [PATCH 14/16] mm, swap: refactor swapoff + add xswap_destroy

From: Baoquan He

Date: Fri Sep 04 2026 - 01:39:25 EST


On 09/03/26 at 03:59pm, Youngjun Park wrote:
> On Thu, Aug 27, 2026 at 05:45:04PM +0800, Baoquan He wrote:
> > +/* Tear down a file-less xswap device by its swap type. */
> > +static int xswap_destroy(int type)
> > +{
> > + struct swap_info_struct *p;
> > +
> > + p = swap_type_to_info(type);
> > + if (!p)
> > + return -EINVAL;
> > +
> > + spin_lock(&swap_lock);
> > + if (!(p->flags & SWP_WRITEOK) || !(p->flags & SWP_XSWAP)) {
> > + spin_unlock(&swap_lock);
> > + return -EINVAL;
> > + }
> > + /* Refuse swapoff while the device is pinned for hibernation */
> > + if (p->flags & SWP_HIBERNATION) {
> > + spin_unlock(&swap_lock);
> > + return -EBUSY;
> > + }
>
> non-blockfile swap device must not be chosen for Hibernation.
> There is no space to hibernate.

You areright.

xswap devices are file-less and zswap-backed with no disk space,
so they cannot host a hibernation image. Sashiko has reported this, v2
excludes SWP_XSWAP devices from hibernation device discovery (both
find_first_swap() and __find_hibernation_swap_type()), so they are never
chosen for hibernation.