From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796122742; b=R6/YZvXXIXGzxksRBEa0YajzxDuBImxkqElKy9GRu4TCHQjqX2ZmR+081C8qbBZ2tELx y2Z/s8eZvwL/K/LlK1tBAkpDxoJj7XtFH0zgPtagyz9/pcgzFEi4pwOgHDzXFeg/8W8za tVypsY3X2GKUEygFNvDu4Sd0mvrNwKyGic/RLlOq+01sd3wgeNiyL518UX15yaUKh5ugW WKxsqQ3q1aKJ4N5fQQFnywa0Gc4ZLr1ReoN9DIdlpb+HztNIWvUjvUuG5sDCWWP1bf3x9 XoglSfP4n6E1bIrng00f2pexRbQuC43RWImjj2jOI8r6pDsYMA4QlNzurAHFmJgslnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796122742; h=DMARC-Filter:DKIM-Signature:X-MC-Rep:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-Mimecast-Spam-Score: X-Mimecast-MFC-PROC-ID:X-Mimecast-Originator: Content-Transfer-Encoding:content-type; bh=QPkCXrHQqhLctzYuZ5CZ8c++vXOJ2VKSO1qdrC8W89U=; b=Y8u/lwm8nH+9N80tzd8VuSHFgra+S6/B2SfgcCOSJQSa5r1yWS4E7X9GkgryL3iz4pqf HzxAme2W/3TkpBEzamUVq9q8w23YPreETQK+AolyWkkEbLXgoLCE17zycaHw/kw99HCpJ NnVXGnep0sNUkK9T1bLdwyOVL7hWskvJVcwZzboXjka8XLiSAtcgZsso/EvTZF0xfMKeU EplFc6S8D4TInsOFQjcVJluklF/2DCG9Fii8OBsFPWxNwAQOKwMqYfpD+UdbsWEtwON6k TVJYFp3zJGF7SBA7daqTzRyxdAUHcx27wCukH+RkHb8N2xrq94z8qVBUd9mZCUJjzVg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Rcypxoks; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 593A6606A327 for ; Tue, 1 Dec 2026 10:59:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 593A6606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Rcypxoks DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796122742; 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=QPkCXrHQqhLctzYuZ5CZ8c++vXOJ2VKSO1qdrC8W89U=; b=RcypxoksLZ4/Vcso5NgoRA/JUVAR3pUtBEJaX+8COoaI9Gyvj8FMl9bbXdtwl03i9VRwrX ytlYFCLEgmPwh/qZ3fnUUN66dKDoOf0xn4Ro+mvnuFby/0CIHF8Vzd/dVDevOOwx1cAAS8 VvT1bx8Lm/RJgCtaU/eqWhh7KRtPsGY= X-MC-Rep: binary re single Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-zaRX1eAnMRmceOcH728eMQ-1; Tue, 1 Dec 2026 10:58:59 +0000 X-MC-Unique: zaRX1eAnMRmceOcH728eMQ-1 X-Mimecast-MFC-AGG-ID: zaRX1eAnMRmceOcH728eMQ_1796122738 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4901562b819so8320183f8f.3 for ; Tue, 01 Dec 2026 02:58:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796122738; x=1796727538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=QPkCXrHQqhLctzYuZ5CZ8c++vXOJ2VKSO1qdrC8W89U=; b=YmrYjmHVpFsf0ZmtFBilnhlGpZQKx6pjDrZJCdfexHvNmDYkwxRS6MqxMdLWpEpiLY 9Yo571dEx9dlf+wjY/fsRgQX7bm1oYstR/eTL76ATd+g9kvxAZZTFR6SmcmJWCoKjRKX MPcMAlC7cA2CNkeMmF1HZGz9vtrL/aBfJ6ONjeGsm6rCRQmKsWw+0ANJDBw4d//ZQlAz BeC4NRO0DAgzm9cw3SCdSgQxvqn/wQM7Uk++TwoZfbyt6qA6d0gGX0Wrt/v8lMNpbq8S kQi9IXTJAPrFygY+kVcu3ZM8MM9nqew+eZP+34df2KreNt14Mqg+9qhSkQFknNENIjHL wJ4Q== X-Forwarded-Encrypted: i=1; AL+hErHSEy/ObVdLCUOAmIpQOgNGPrX1IAQbHiEZQ/ScwCxS1jjN9ubPcAQRq0URHItoRO3nEmCXK5Y3zTvsrFlotg==@lists.linux.dev X-Gm-Message-State: APuU4Z/rtCdBazv9LYnHLZiIpmLbWWewMRsXPVATC8+iS6DqXlK/CZev 0suZ3Ldfbp0PeX7fyiiMbR5oovVA0hiCdkDmtvySY8+uqCCGG7rQ2pJJgMOSWkW53p9CFBcRvcO YRFHJvArWK+TKpv5iIsXDlfjCbalEukHjhOCa+pO7EoANnNqqvGmqyK1PeAGLqGi26YbDmTsR4K d0 X-Gm-Gg: AZFdTZfRuWwouxPMwHoll52mEdK8tgH/GJc3TbIedJOrioec/2/oYu+2+mqbaQ0P6OI UWmHVTii0vCFiCy7REIuwKVdMEhIo/Ccg0r1sD7+/8gu4aAGBBhw2d2TwicP35tO3GWTp7dWJ4g NntuEfaiEnT8UjTDbB08/+ZGt79XJhhA3RtddI7NLZu+IhbIpdpjCfFo1sLaRb6AEHIviYmXhfG OHYfBWKMtEY+lsVDu10z/Nc1lbk8AZYIScraHe0W3Hn9Z/ZzJXrG/ngxOPR+Lobh86g8hFBojsm 616nHOVSMGjwXr+iOLF9WdC26zUia+Fm2g9/u4goew3kLzhfAMJxLErgetZ6o8NYydxxM5ZRAEa 8znfziZzW0Em3+UxUt2vOtUwTtxBLSnWMnNxldO8ZtLW2a0Bh9E1bVl9blx0G/zdhfQWvrkzH2B 0V5oW6y3f4c3mo4x+YhhPeQnPB18UnHaF6RzAFpatO X-Received: by 2002:a5d:6f05:0:b0:4ab:f5b0:a7ed with SMTP id ffacd0b85a97d-4abf5b0a91cmr65277803f8f.12.1796122738427; Tue, 01 Dec 2026 02:58:58 -0800 (PST) X-Received: by 2002:a5d:6f05:0:b0:4ab:f5b0:a7ed with SMTP id ffacd0b85a97d-4abf5b0a91cmr65277766f8f.12.1796122738019; Tue, 01 Dec 2026 02:58:58 -0800 (PST) Received: from mszeredi-thinkpadt14gen6.redhat.corp (193-226-214-34.pool.digikabel.hu. [193.226.214.34]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf685asm72464829f8f.20.2026.12.01.02.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 02:58:57 -0800 (PST) From: Miklos Szeredi To: fuse-devel@lists.linux.dev, virtualization@lists.linux.dev Cc: Li Wang , German Maglione , Stefan Hajnoczi Subject: [PATCH v3 2/5] virtiofs: don't abort DAX removemapping on allocation failure Date: Tue, 1 Dec 2026 11:58:50 +0100 Message-ID: <20261201105855.430993-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201105855.430993-1-mszeredi@redhat.com> References: <20261201105855.430993-1-mszeredi@redhat.com> X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: TENbr3Jd2G-MlPKDT1WcXcUKonJclXlPu27zb4oEr1M_1796122738 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true dmap_removemapping_list() allocates an array of fuse_removemapping_one entries to batch the FUSE_REMOVEMAPPING request, and returns -ENOMEM if that fails. The batch array is only a convenience: dmap_removemapping_one() already sends a single entry entirely from the stack. Move it above dmap_removemapping_list() and use it to remove the ranges one at a time when the array cannot be allocated. That is slower, but it cannot fail for lack of memory, and it only happens under memory pressure. While at it, initialize ret, which was left uninitialized if the list passed in was empty. The current caller checks for that beforehand, so this is not a bug today. Fixes: c2d0ad00d948 ("virtiofs: implement dax read/write operations") Reviewed-by: Li Wang Signed-off-by: Miklos Szeredi --- fs/fuse/dax.c | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index e20a5ae6fecc..e60665bb597e 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -248,18 +248,46 @@ static int fuse_send_removemapping(struct inode *inode, return fuse_simple_request(fm, &args); } +static int dmap_removemapping_one(struct inode *inode, + struct fuse_dax_mapping *dmap) +{ + struct fuse_removemapping_one forget_one; + struct fuse_removemapping_in inarg; + + memset(&inarg, 0, sizeof(inarg)); + inarg.count = 1; + memset(&forget_one, 0, sizeof(forget_one)); + forget_one.moffset = dmap->window_offset; + forget_one.len = dmap->length; + + return fuse_send_removemapping(inode, &inarg, &forget_one); +} + static int dmap_removemapping_list(struct inode *inode, unsigned int num, struct list_head *to_remove) { struct fuse_removemapping_one *remove_one, *ptr; struct fuse_removemapping_in inarg; struct fuse_dax_mapping *dmap; - int ret, i = 0, nr_alloc; + int ret = 0, i = 0, nr_alloc; nr_alloc = min_t(unsigned int, num, FUSE_REMOVEMAPPING_MAX_ENTRY); remove_one = kmalloc_objs(*remove_one, nr_alloc, GFP_NOFS); - if (!remove_one) - return -ENOMEM; + if (!remove_one) { + /* + * Fall back to removing the ranges one at a time, which needs + * no allocation. It is slower, but this only happens under + * memory pressure. The caller ignores the error and recycles + * the ranges regardless, so bailing out here would just leave + * the server holding mappings for an inode that is gone. + */ + list_for_each_entry(dmap, to_remove, list) { + ret = dmap_removemapping_one(inode, dmap); + if (ret) + break; + } + return ret; + } ptr = remove_one; list_for_each_entry(dmap, to_remove, list) { @@ -350,21 +378,6 @@ static void inode_reclaim_dmap_range(struct fuse_conn_vdax *fcd, spin_unlock(&fcd->lock); } -static int dmap_removemapping_one(struct inode *inode, - struct fuse_dax_mapping *dmap) -{ - struct fuse_removemapping_one forget_one; - struct fuse_removemapping_in inarg; - - memset(&inarg, 0, sizeof(inarg)); - inarg.count = 1; - memset(&forget_one, 0, sizeof(forget_one)); - forget_one.moffset = dmap->window_offset; - forget_one.len = dmap->length; - - return fuse_send_removemapping(inode, &inarg, &forget_one); -} - /* * It is called from evict_inode() and by that time inode is going away. So * this function does not take any locks like fi->vdax->sem for traversing -- 2.56.1