Message ID | 20240123-zonefs_nofs-v1-1-cc0b0308ef25@wdc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-35016-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp222410dyi; Tue, 23 Jan 2024 01:45:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4MwxrUmbPEV/H1jJ/XRTLyWwxMvciB5z9yS+Zywsva3cokINTm7/cT+NE7MBHg6Knk9Id X-Received: by 2002:aa7:da53:0:b0:55a:9038:ce61 with SMTP id w19-20020aa7da53000000b0055a9038ce61mr659939eds.59.1706003128018; Tue, 23 Jan 2024 01:45:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706003128; cv=pass; d=google.com; s=arc-20160816; b=jFMFjL5sKq92WfWW7JVeHLlea/2AK8kUmIQsOZrmkoDxcrJvMjbYxVWMj8LOmegLs0 7UoNZIBLB9WWfM/xGfTOY33ClNIzIZaTMc9M7FAO8I+R3vZn4QjjZeED7wl6SluR7Ihi kNKPYXdjPrAeXWZQ+AbT6sHX+BHg37mKCM/r2kmAVxxLawZHDtywmRmHJBw4GY1AxfUD /1Sg9B1DqnDm3CMVUbRkQ3/j375c7bWFO6EXoRvbKKTWMcgrPv8E+mkfw8xYub0rM9Vb 9NS4hsSLDmYPbw1nely/OAkjBvxKJTb1sVMRBqRgp7Xu99rfIFWG7UM32GfKTW0JLWO2 FN5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=xwNR4/EZjtvmjPU5B92P0twDrTPGvgcwhXfRvMp8W3M=; fh=eAi0k/flagmBX9JQ48PVdzOcGziLUreSp20hhkaGOsw=; b=anmQljmUDT6252Os8N7GTYabjxVfY+0RbQ6U91gCZDa0Bwv/DnXV9B26gpnM+Qzr24 eMnHgurTPINR65sUQq+EnIvQsdVx0tpQnaWXkfqLSlgeaz5qySqMjiTSC+5LV9kqCayp TywrZNkTaf2UJnlU6qdACjbdiWtIFs0+K7IwH0dYmpmoqEapMIw5O3CiXNev2ztiDnsI /8YiqYCj3RxKBLxsv+mUUBcmlPOqn2CzHqSCsvQp1igl905ps3gZw68K0NCNKoNp31bb eShPidb6JSs/TsieGZ2NTB5zEP+fuvnUnBuFEGMGttqurP6imY9K4nHhvJcNqPnPv/H1 uxMA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=WzxfBXoS; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: domain of linux-kernel+bounces-35016-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35016-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t1-20020a056402240100b0055a8321f767si3825090eda.258.2024.01.23.01.45.27 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 01:45:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35016-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@wdc.com header.s=dkim.wdc.com header.b=WzxfBXoS; arc=pass (i=1 spf=pass spfdomain=wdc.com dkim=pass dkdomain=wdc.com dmarc=pass fromdomain=wdc.com); spf=pass (google.com: domain of linux-kernel+bounces-35016-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35016-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A18E31F22F79 for <ouuuleilei@gmail.com>; Tue, 23 Jan 2024 09:45:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB5025D8E4; Tue, 23 Jan 2024 09:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="WzxfBXoS" Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) (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 4C3DA5BAFA; Tue, 23 Jan 2024 09:44:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.143.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706003044; cv=none; b=c4tJ+CkKgENaodgtw09qYKWOnaSamcQVGmuZHZ4fu3w6E7nh5LmOibJNtSNCpbfjIxBTb1Wp+V0KqE35tlDjEpiMrynKPV4sc257PsyazSpQbplChykubdi7NBL5dCdAh8tBWgolQgsYchmVKKMTWmWf+DRuDrbfmfIn6BofHKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706003044; c=relaxed/simple; bh=USx+V+gR/5Lk+0GJr2lbq1FeCI2pXKMzpek+ct39bMM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y3d+ZSffVEdPq1YWX7Y7QJAVDZgL3GyLLSpq7kSefUuJIBfu3S/MVO/eY8TbukYSNbc1NOFfNbvMbVEYpmTM14Jf1qP10sye8YHbF35ZQ07NaGcMGC2uN8xM4rJPaVS+zQuFaPzwpR5rkFAGiuifODD2QhQdNEYBmaCWf/bIHQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=WzxfBXoS; arc=none smtp.client-ip=68.232.143.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1706003042; x=1737539042; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=USx+V+gR/5Lk+0GJr2lbq1FeCI2pXKMzpek+ct39bMM=; b=WzxfBXoSysLCoYvWX9Wk00wDWTjKLQZ+eJlTxBnzw9bmmSvo2NNrikn9 l6rqo5mnfZ8d6VnJ+xH4zdChm1qCSbxkQHhdc0EDyDjrffbsSB3hLSOuk lXwDrZXD5kPrUs6dOgN4I6KprRSvsvBxF4JIqUsUONmhfGEzUHUTNO1bJ k4amxZ1SqjOY309xDtlFQtpOY2SMjcYO2PCZ2P+iFmQ20o0OjDrt+nj6W JtGOFUbpKo7vHDnAo2TUQD3Z852jnBlsumKJxW24PLh1COvrEaNv7Yos4 9R5qXx0CVTuo1qb/kuxQHUK+3++MaEOV5unPDjHvoR76yZ+cwJ5b7V+PL Q==; X-CSE-ConnectionGUID: OLgmSsDqRTC4a2U/r99VOA== X-CSE-MsgGUID: FvWCBe8QRtWec/o+td0l5A== X-IronPort-AV: E=Sophos;i="6.05,214,1701100800"; d="scan'208";a="7514650" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 23 Jan 2024 17:43:54 +0800 IronPort-SDR: SYyrr2sfevEd2YeeThp4yjSt6XDT1YqATLjmPIuNAYwwoqCCmbs5PoYMlJFbPFp70n3YsNU0YA Llkgv1jyt/Ww== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 23 Jan 2024 00:53:57 -0800 IronPort-SDR: P3OOCgnEiOoiT5kro0hhE2puMVinRxHrlbO9eu21ZDBzEa4K+SZFeEYuAtZNHIp7Zz4lNvn0Hv sg9b/x3sDNFA== WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 23 Jan 2024 01:43:50 -0800 From: Johannes Thumshirn <johannes.thumshirn@wdc.com> Date: Tue, 23 Jan 2024 01:43:42 -0800 Subject: [PATCH 1/5] zonefs: pass GFP_KERNEL to blkdev_zone_mgmt() call Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240123-zonefs_nofs-v1-1-cc0b0308ef25@wdc.com> References: <20240123-zonefs_nofs-v1-0-cc0b0308ef25@wdc.com> In-Reply-To: <20240123-zonefs_nofs-v1-0-cc0b0308ef25@wdc.com> To: Damien Le Moal <dlemoal@kernel.org>, Naohiro Aota <naohiro.aota@wdc.com>, Mike Snitzer <snitzer@kernel.org>, dm-devel@lists.linux.dev, Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>, David Sterba <dsterba@suse.com>, Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>, Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>, Chaitanya Kulkarni <kch@nvidia.com> Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Johannes Thumshirn <johannes.thumshirn@wdc.com>, "Matthew Wilcox (Oracle)" <willy@infradead.org> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706003027; l=967; i=johannes.thumshirn@wdc.com; s=20230613; h=from:subject:message-id; bh=USx+V+gR/5Lk+0GJr2lbq1FeCI2pXKMzpek+ct39bMM=; b=CqyzAxjrtVF3h1COiTD1vUp/FvMExp42Wy7b72mtI/+VK3Cc+nQQgb8KdYlLZ32Qn9DwLPhCQ 2dpOdt+5tGWBTomHGv+qgGPRnYLx+GcwkDEU2N7SunPs8Zz3A98pXO5 X-Developer-Key: i=johannes.thumshirn@wdc.com; a=ed25519; pk=TGmHKs78FdPi+QhrViEvjKIGwReUGCfa+3LEnGoR2KM= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788873936115001776 X-GMAIL-MSGID: 1788873936115001776 |
Series |
block: remove gfp_mask for blkdev_zone_mgmt()
|
|
Commit Message
Johannes Thumshirn
Jan. 23, 2024, 9:43 a.m. UTC
Pass GFP_KERNEL instead of GFP_NOFS to the blkdev_zone_mgmt() call in
zonefs_zone_mgmt().
As as zonefs_zone_mgmt() and zonefs_inode_zone_mgmt() are never called
from a place that can recurse back into the filesystem on memory reclaim,
it is save to call blkdev_zone_mgmt() with GFP_KERNEL.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/zonefs/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, 23 Jan 2024, Johannes Thumshirn wrote: > Pass GFP_KERNEL instead of GFP_NOFS to the blkdev_zone_mgmt() call in > zonefs_zone_mgmt(). > > As as zonefs_zone_mgmt() and zonefs_inode_zone_mgmt() are never called > from a place that can recurse back into the filesystem on memory reclaim, > it is save to call blkdev_zone_mgmt() with GFP_KERNEL. > > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > --- > fs/zonefs/super.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c > index 93971742613a..63fbac018c04 100644 > --- a/fs/zonefs/super.c > +++ b/fs/zonefs/super.c > @@ -113,7 +113,7 @@ static int zonefs_zone_mgmt(struct super_block *sb, > > trace_zonefs_zone_mgmt(sb, z, op); > ret = blkdev_zone_mgmt(sb->s_bdev, op, z->z_sector, > - z->z_size >> SECTOR_SHIFT, GFP_NOFS); > + z->z_size >> SECTOR_SHIFT, GFP_KERNEL); > if (ret) { > zonefs_err(sb, > "Zone management operation %s at %llu failed %d\n", > > -- > 2.43.0 zonefs_inode_zone_mgmt calls lockdep_assert_held(&ZONEFS_I(inode)->i_truncate_mutex); - so, this function is called with the mutex held - could it happen that the GFP_KERNEL allocation recurses into the filesystem and attempts to take i_truncate_mutex as well? i.e. GFP_KERNEL -> iomap_do_writepage -> zonefs_write_map_blocks -> zonefs_write_iomap_begin -> mutex_lock(&zi->i_truncate_mutex) Mikulas
On Tue, Jan 23, 2024 at 09:39:02PM +0100, Mikulas Patocka wrote: > > > On Tue, 23 Jan 2024, Johannes Thumshirn wrote: > > > Pass GFP_KERNEL instead of GFP_NOFS to the blkdev_zone_mgmt() call in > > zonefs_zone_mgmt(). > > > > As as zonefs_zone_mgmt() and zonefs_inode_zone_mgmt() are never called > > from a place that can recurse back into the filesystem on memory reclaim, > > it is save to call blkdev_zone_mgmt() with GFP_KERNEL. > > > > Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> > > --- > > fs/zonefs/super.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c > > index 93971742613a..63fbac018c04 100644 > > --- a/fs/zonefs/super.c > > +++ b/fs/zonefs/super.c > > @@ -113,7 +113,7 @@ static int zonefs_zone_mgmt(struct super_block *sb, > > > > trace_zonefs_zone_mgmt(sb, z, op); > > ret = blkdev_zone_mgmt(sb->s_bdev, op, z->z_sector, > > - z->z_size >> SECTOR_SHIFT, GFP_NOFS); > > + z->z_size >> SECTOR_SHIFT, GFP_KERNEL); > > if (ret) { > > zonefs_err(sb, > > "Zone management operation %s at %llu failed %d\n", > > > > -- > > 2.43.0 > > zonefs_inode_zone_mgmt calls > lockdep_assert_held(&ZONEFS_I(inode)->i_truncate_mutex); - so, this > function is called with the mutex held - could it happen that the > GFP_KERNEL allocation recurses into the filesystem and attempts to take > i_truncate_mutex as well? > > i.e. GFP_KERNEL -> iomap_do_writepage -> zonefs_write_map_blocks -> > zonefs_write_iomap_begin -> mutex_lock(&zi->i_truncate_mutex) zonefs doesn't have a ->writepage method, so writeback can't be called from memory reclaim like this. -Dave.
On 1/24/24 08:21, Dave Chinner wrote: > On Tue, Jan 23, 2024 at 09:39:02PM +0100, Mikulas Patocka wrote: >> >> >> On Tue, 23 Jan 2024, Johannes Thumshirn wrote: >> >>> Pass GFP_KERNEL instead of GFP_NOFS to the blkdev_zone_mgmt() call in >>> zonefs_zone_mgmt(). >>> >>> As as zonefs_zone_mgmt() and zonefs_inode_zone_mgmt() are never called >>> from a place that can recurse back into the filesystem on memory reclaim, >>> it is save to call blkdev_zone_mgmt() with GFP_KERNEL. >>> >>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> >>> --- >>> fs/zonefs/super.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c >>> index 93971742613a..63fbac018c04 100644 >>> --- a/fs/zonefs/super.c >>> +++ b/fs/zonefs/super.c >>> @@ -113,7 +113,7 @@ static int zonefs_zone_mgmt(struct super_block *sb, >>> >>> trace_zonefs_zone_mgmt(sb, z, op); >>> ret = blkdev_zone_mgmt(sb->s_bdev, op, z->z_sector, >>> - z->z_size >> SECTOR_SHIFT, GFP_NOFS); >>> + z->z_size >> SECTOR_SHIFT, GFP_KERNEL); >>> if (ret) { >>> zonefs_err(sb, >>> "Zone management operation %s at %llu failed %d\n", >>> >>> -- >>> 2.43.0 >> >> zonefs_inode_zone_mgmt calls >> lockdep_assert_held(&ZONEFS_I(inode)->i_truncate_mutex); - so, this >> function is called with the mutex held - could it happen that the >> GFP_KERNEL allocation recurses into the filesystem and attempts to take >> i_truncate_mutex as well? >> >> i.e. GFP_KERNEL -> iomap_do_writepage -> zonefs_write_map_blocks -> >> zonefs_write_iomap_begin -> mutex_lock(&zi->i_truncate_mutex) > > zonefs doesn't have a ->writepage method, so writeback can't be > called from memory reclaim like this. And also, buffered writes are allowed only for conventional zone files, for which we never do zone management. For sequential zone files which may have there zone managed with blkdev_zone_mgmt(), only direct writes are allowed. > > -Dave.
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index 93971742613a..63fbac018c04 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -113,7 +113,7 @@ static int zonefs_zone_mgmt(struct super_block *sb, trace_zonefs_zone_mgmt(sb, z, op); ret = blkdev_zone_mgmt(sb->s_bdev, op, z->z_sector, - z->z_size >> SECTOR_SHIFT, GFP_NOFS); + z->z_size >> SECTOR_SHIFT, GFP_KERNEL); if (ret) { zonefs_err(sb, "Zone management operation %s at %llu failed %d\n",