From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6127A3DD500 for ; Thu, 14 May 2026 08:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778748028; cv=none; b=ROPiGbtsGYvBS4A0npzcjv2O6GVRqLddo8WKp9RBgA5qcZJe5Pwt22N7tYU+NV6ZfgvBrZ0U1mFvINuLWbUuR8+jTIGGUy9teP4T/s9zmbAxHv3RhvpxAupp0omPT1da+KNOb+UZaA83ov9vm2/Ufr9QKkBx1nHd1d7dFnn/NpM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778748028; c=relaxed/simple; bh=zTxe/SnVu5xZu0oog1Lbc0z40Tk0luVb/dX5MX7r754=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FXYRncIISkxtedZEi9ATlYexmc4FCmRV4ifaS/cqpmaaPJEuypHTIM/14lp9S+y1b9KDXnbepY42a7lPyXy+P5x5TX9mZpwEg/ieURUaTBy3/y6TfP5PffqFV39ob/2TaQQGHaGpVs+by11hXW/Q0uc6LU46se3G1N4AG4mE9og= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=r0otTCZv; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="r0otTCZv" Date: Thu, 14 May 2026 16:40:18 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1778748024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/pH5uEoZQwt6RlFP9VMsKY2dxNsBMCy8toEtQrZFkg8=; b=r0otTCZv+ToFCTCTHd6z/r69gvYJ2V6m4G5thhCGZaQuM1ZKBI4oszFw5XZDj4xBXcH4Au Rl7NJZl0B6KSa44ZSlftZ28VPeLLi4lz8qfPmrbf1x3AG2K2fNYQO+aJnsJNnFDYrkxghk LYa+BMi432Uf2KJr2B7amtXeZWyw5jk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Baoquan He To: Kairui Song Cc: linux-mm@kvack.org, akpm@linux-foundation.org, chrisl@kernel.org, usama.arif@linux.dev, baohua@kernel.org, nphamcs@gmail.com, shikemeng@huaweicloud.com, youngjun.park@lge.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/3] mm/swap: use swap_ops to register swap device's methods Message-ID: References: <20260512104201.716213-1-baoquan.he@linux.dev> <20260512104201.716213-3-baoquan.he@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT On 05/14/26 at 02:41pm, Kairui Song wrote: > On Thu, May 14, 2026 at 10:06 AM Baoquan He wrote: > > > > On 05/13/26 at 01:53am, Kairui Song wrote: > > > On Tue, May 12, 2026 at 6:50 PM Baoquan He wrote: ......snip... > > > > diff --git a/mm/swapfile.c b/mm/swapfile.c > > > > index 4840fd40f36f..8c42632e6765 100644 > > > > --- a/mm/swapfile.c > > > > +++ b/mm/swapfile.c > > > > @@ -3780,6 +3780,15 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) > > > > goto free_swap_zswap; > > > > } > > > > > > > > + /* > > > > + * init_swap_ops() sets si->ops based on flags. It does not need > > > > + * swapon_mutex, and must complete before enable_swap_info() > > > > + * exposes the device. > > > > + */ > > > > + error = init_swap_ops(si); > > > > + if (error) > > > > + goto bad_swap_unlock_inode; > > > > > > I checked the comment above previously and it looked good. But the > > > error label seems not that correct after double check. inode->i_flags > > > will keep the S_SWAPFILE flag. Maybe something like add a > > > inode->i_flags &= ~S_SWAPFILE here and goto free_swap_zswap. Sorry I > > > didn't check this part carefully last time. > > > > Right. How about moving it zswap_swapon() because it only relies on > > si->flags setting currently? > > You mean before zswap_swapon()? Then that sounds good to me. Yeah, just before zswap_swapon(). I missed a word.