From patchwork Mon Sep 23 10:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis Henriques (SUSE)" X-Patchwork-Id: 1988551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=C9zgBXGN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=cbuo=qv=vger.kernel.org=linux-ext4+bounces-4273-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XC0B05Ddbz1xsn for ; Mon, 23 Sep 2024 20:49:44 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XC0B038lhz4wcL for ; Mon, 23 Sep 2024 20:49:44 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4XC0B035qXz4wnw; Mon, 23 Sep 2024 20:49:44 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=139.178.88.99 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1727088584; cv=pass; b=yfOUW4ZpQ4sb4bkMx4EJXU0h+DnuzPK2Fj4dEUrvAqnIkiG82CWCa3MOVDWmsnjv/eUOawymjMEfw5z2jpb8PalmA8BckSzIYdEmDEaL4C6oiLR3kItgGoEM6rKJIt9ZgZbo4p2QeKIfbVzd7pYOvFQwT1KijkTucrHpozFp8tqZs/ML2Ngi2eZavAhNvUj3NuAQlxkm552qUD+0icddCfgntR0bSmPJaSVWki+1l31xumpzI6dPvwJoPFSjiV6Tjo615EokByv+lXd5vEHJfEcACejRseW0tYLkg16FIpqJt0ajOzvBpegaDWri7xYWbAF1P4WrCtLWawj1yQbkbA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1727088584; c=relaxed/relaxed; bh=0el6xdbuEtFnFMlbAu4zA1Zhc8E2Sw9sLTTq195ArnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TbAtyD7xs9b3cxbHaLvlJfZe1tMdl26J09ABoEBaOWBnua9OyeaP8UzbOnOwVUDrrxYzJenVm3DSyPzdPWPbS1Kdt0jVgd4NxDm19lzqCL2UcwSfkXPbhB1JJYjRCaemojb9kQnsyfYbNezLrA0NkJJdE5WHonN3qutwtULP+CxieRLDe/UHfU1z4QTWRb4iKB4fFQqGIqDqZ7hOKOtSnuiuPjdCGrP8cJJKofjxRMF+2sDx4HXZfGK8uEqFNh+vZRB1fKZ3biPIBSG8lLsocD1zxpmVGd7cCk5dMUUlovWt0yzZ1t+ZsRTeKxLsCsCh4RxrXkF9WIvWtOmg/v7UvA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=C9zgBXGN; dkim-atps=neutral; spf=pass (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4273-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=C9zgBXGN; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4273-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4XC0B00psYz4wcL for ; Mon, 23 Sep 2024 20:49:44 +1000 (AEST) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 140DC281A7E for ; Mon, 23 Sep 2024 10:49:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 734CD195FEF; Mon, 23 Sep 2024 10:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="C9zgBXGN" X-Original-To: linux-ext4@vger.kernel.org Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 57984197A98 for ; Mon, 23 Sep 2024 10:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727088570; cv=none; b=nDxbAhg/QJlg0+fFxJEOsWJ0j047hisr8De9ktyfghj4pa0m0GR8Du2nCLFosNYwJFG3ifxqF11cUWQ76Y6NGaxUFNXBK9bA9rxWwtB+Sj/R8Bm1AjXxoutMqca+KkQ6cvuK039w3oWeMrF2oizldEn+L1xVYtzKUzx5MbP4tYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727088570; c=relaxed/simple; bh=7KWMRCfLshJan+v1YjbxtnHR81BOQimjwuapGh0YCt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ch9CgTGpVXqMKK2gG7uAd1TJ+P/9HL3R4SC6iaNRHgVzNWcQJ+gCgFh5g4/Mg7tS+CuZb+ayljVmh/JtcvemoF8Vu98unHpVBvhqUOVbj0TbzmT8pCX0pbtgc4EyPpsP+EMWogv3BITlU37IqwJ1fMfefG7Mh4UbS2zr56+qc3E= 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=C9zgBXGN; arc=none smtp.client-ip=95.215.58.178 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 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1727088566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0el6xdbuEtFnFMlbAu4zA1Zhc8E2Sw9sLTTq195ArnA=; b=C9zgBXGNgF11TSAoOFJbOP+73/afONE/qTKlc1UrkNi021PD0EtS6ADpQ357pnNFob4yuv 6xBNnk4v06C6Pocy8zCH/tkVf1c/jZsSHq0Hrb+WHDmQR7phPJZ8r3X6d6LWqpQt6GyEPE SLEyKBVFeZ31eu6/IpOVZIjbLRyMTHU= From: "Luis Henriques (SUSE)" To: Theodore Ts'o , Andreas Dilger , Jan Kara , Harshad Shirwadkar Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis Henriques (SUSE)" Subject: [PATCH v2 1/2] ext4: use handle to mark fc as ineligible in __track_dentry_update() Date: Mon, 23 Sep 2024 11:49:08 +0100 Message-ID: <20240923104909.18342-2-luis.henriques@linux.dev> In-Reply-To: <20240923104909.18342-1-luis.henriques@linux.dev> References: <20240923104909.18342-1-luis.henriques@linux.dev> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Calling ext4_fc_mark_ineligible() with a NULL handle is racy and may result in a fast-commit being done before the filesystem is effectively marked as ineligible. This patch fixes the calls to this function in __track_dentry_update() by adding an extra parameter to the callback used in ext4_fc_track_template(). Suggested-by: Jan Kara Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Jan Kara --- fs/ext4/fast_commit.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 3926a05eceee..c330efd771d1 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -372,7 +372,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handl */ static int ext4_fc_track_template( handle_t *handle, struct inode *inode, - int (*__fc_track_fn)(struct inode *, void *, bool), + int (*__fc_track_fn)(handle_t *handle, struct inode *, void *, bool), void *args, int enqueue) { bool update = false; @@ -389,7 +389,7 @@ static int ext4_fc_track_template( ext4_fc_reset_inode(inode); ei->i_sync_tid = tid; } - ret = __fc_track_fn(inode, args, update); + ret = __fc_track_fn(handle, inode, args, update); mutex_unlock(&ei->i_fc_lock); if (!enqueue) @@ -413,7 +413,8 @@ struct __track_dentry_update_args { }; /* __track_fn for directory entry updates. Called with ei->i_fc_lock. */ -static int __track_dentry_update(struct inode *inode, void *arg, bool update) +static int __track_dentry_update(handle_t *handle, struct inode *inode, + void *arg, bool update) { struct ext4_fc_dentry_update *node; struct ext4_inode_info *ei = EXT4_I(inode); @@ -428,14 +429,14 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) if (IS_ENCRYPTED(dir)) { ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_ENCRYPTED_FILENAME, - NULL); + handle); mutex_lock(&ei->i_fc_lock); return -EOPNOTSUPP; } node = kmem_cache_alloc(ext4_fc_dentry_cachep, GFP_NOFS); if (!node) { - ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_NOMEM, NULL); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_NOMEM, handle); mutex_lock(&ei->i_fc_lock); return -ENOMEM; } @@ -447,7 +448,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update) node->fcd_name.name = kmalloc(dentry->d_name.len, GFP_NOFS); if (!node->fcd_name.name) { kmem_cache_free(ext4_fc_dentry_cachep, node); - ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_NOMEM, NULL); + ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_NOMEM, handle); mutex_lock(&ei->i_fc_lock); return -ENOMEM; } @@ -569,7 +570,8 @@ void ext4_fc_track_create(handle_t *handle, struct dentry *dentry) } /* __track_fn for inode tracking */ -static int __track_inode(struct inode *inode, void *arg, bool update) +static int __track_inode(handle_t *handle, struct inode *inode, void *arg, + bool update) { if (update) return -EEXIST; @@ -607,7 +609,8 @@ struct __track_range_args { }; /* __track_fn for tracking data updates */ -static int __track_range(struct inode *inode, void *arg, bool update) +static int __track_range(handle_t *handle, struct inode *inode, void *arg, + bool update) { struct ext4_inode_info *ei = EXT4_I(inode); ext4_lblk_t oldstart; From patchwork Mon Sep 23 10:49:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis Henriques (SUSE)" X-Patchwork-Id: 1988552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vhlOKH5w; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=s0kt=qv=vger.kernel.org=linux-ext4+bounces-4274-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XC0BL31xGz1xsM for ; Mon, 23 Sep 2024 20:50:02 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XC0BG4pCxz4wcL for ; Mon, 23 Sep 2024 20:49:58 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4XC0BG4lSyz4wcr; Mon, 23 Sep 2024 20:49:58 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45e3:2400::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1727088598; cv=pass; b=WsZYoxzddf9g3vR0pmj04VAyLHwKJHKN02LREcQSxKBO65y1UQq9ncUlp4tINDQDuusDZGmza1WPgoOsdbUU+OGZCT9tt95F/rc+E57tnWjs8HE6NoLGl2Pch4aqTXwt7mBkNcbEoEbJppV+f84Aqc2qHrLaeRjGoBQ/atXA32XR5PHkPzwM+WOidF7fidFMzkyL4GDMuBKIPXJbpH2QGjlOyVRT2nifgx4cRQa47+Ho2P9YfPyz0zIkORDq6yndneDbc0fNp/KxyywAejL+qzo4AufDN+fXo2AALjlMv/PbvqAjHHTmZyk+yCMFi9xlkrl5f9MfwGzEH2AkTuHmOQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1727088598; c=relaxed/relaxed; bh=B7NTCO8xwKE6PoRVYTk0JVzux063/kz2KYFXLVwzRBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ixq0e7EAbcFn5pYix12o4zN9PH6qiHjdU2NrfaC2wUzi3/yjU00F9O9Xe5dm3Z+TnH9pVQFj+GsYK4UFwaeuonJlPAORlgwvRnpeJEer/0EmMT2q9dKjrmTj+AHh3zjbppK51OCstJNcM2DyTtxZ19e5HlKGzVX5BgPdDyJ4KeYUzdEpzHrW7lay9L7m6AHDA7s83NIqpTJVZolD0wocfEuR9NcSnPrEawuPhLKEN9JM0+CkJoK22sEROeoCSZtguhe2hwP6lvt4PU9Zm7dbZk/UDvv5+69cJO0Bi7yTrZT3/2+9m2DPwaxbQFnS9CG7x7a2RNweLDVFlXw/mzP66g== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vhlOKH5w; dkim-atps=neutral; spf=pass (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4274-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vhlOKH5w; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4274-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4XC0BG2TwVz4wcL for ; Mon, 23 Sep 2024 20:49:58 +1000 (AEST) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0F0E0281CCF for ; Mon, 23 Sep 2024 10:49:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D262C198A36; Mon, 23 Sep 2024 10:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vhlOKH5w" X-Original-To: linux-ext4@vger.kernel.org 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 9E90C198851 for ; Mon, 23 Sep 2024 10:49:31 +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=1727088573; cv=none; b=uR5xtIvPxMaUj2UjDXay7ut5I4PXfWaaXB4i7io16vfAnQeNdyy77ym2FMhWVCEl+FAaFHXS6EGem2B2JknfxpoJCtZTpqhm06x2b28VTRNeGFKILqsv+omMgX+MSvxbtHabUudSRW4nIK0ZvHwjULczQvP1vZxxe9jzQPHNktI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727088573; c=relaxed/simple; bh=I2CnKuu2Uv7vhpRKiK0wqZI4jJoCqN9SGJidJoCPvN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C+hvMmCqpHCIsWaA8JCyT7KOE7T3NJWlfByge2pk6mCFSbbj7jjuDT4JmSXxMS6USIVzgodxwISPRl70J91pTZO7CL6riCOd+ue0uuejelvAs/HNtSS49/0LIfpoXsoBelmhm4Mz85oQAuKylkSJ2AsUEerLe+zHJgQMJh4I7YI= 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=vhlOKH5w; 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 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1727088569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B7NTCO8xwKE6PoRVYTk0JVzux063/kz2KYFXLVwzRBU=; b=vhlOKH5wDWitz2nzyeokLmABTqgDHXfUSH+LXihoZZ+C4JudpwI4Htb35/nBTJDkCE3GQM x8QZLBYeODfrpL21ERBGrtpJ33leddA/5yjnUg25taEe7YRyTD3JPGyGCY1GZ3kr9N1yCG Xuy7PKsefzW26Wv3Osg4PO7j+fMAHoI= From: "Luis Henriques (SUSE)" To: Theodore Ts'o , Andreas Dilger , Jan Kara , Harshad Shirwadkar Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis Henriques (SUSE)" Subject: [PATCH v2 2/2] ext4: mark fc as ineligible using an handle in ext4_xattr_set() Date: Mon, 23 Sep 2024 11:49:09 +0100 Message-ID: <20240923104909.18342-3-luis.henriques@linux.dev> In-Reply-To: <20240923104909.18342-1-luis.henriques@linux.dev> References: <20240923104909.18342-1-luis.henriques@linux.dev> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Calling ext4_fc_mark_ineligible() with a NULL handle is racy and may result in a fast-commit being done before the filesystem is effectively marked as ineligible. This patch moves the call to this function so that an handle can be used. If a transaction fails to start, then there's not point in trying to mark the filesystem as ineligible, and an error will eventually be returned to user-space. Suggested-by: Jan Kara Signed-off-by: Luis Henriques (SUSE) Reviewed-by: Jan Kara --- fs/ext4/xattr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 46ce2f21fef9..aea9e3c405f1 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -2559,6 +2559,8 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name, error = ext4_xattr_set_handle(handle, inode, name_index, name, value, value_len, flags); + ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, + handle); error2 = ext4_journal_stop(handle); if (error == -ENOSPC && ext4_should_retry_alloc(sb, &retries)) @@ -2566,7 +2568,6 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name, if (error == 0) error = error2; } - ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, NULL); return error; }