From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049458; b=2zxHCp+ud819eMoFw72BgmdzrUJleRwMvXIhsm+lXsyFxSq/xLOkVejQXmQJjbpD1S9P hYiAhWkGlKjduxdDtM9IZd51sDMD6l2bNnR1oZxRS5XrKyYF0bI2KF/mXHcQy9/2d1yn8 U5D1k6jYZEFj3h8WBhpIXsCzgkWdo2r9BVN7KPjOaclklHeRFBzLjeydEm5KWnqXIh42P mbiFFivyV//XNa3wsK2DSnk7n1H4xM7aZyulY2c70Um6hy2RYsetD3RFUYaV0r0IBj1wE Lp9/QbEDCyX9hZ/PoM8iAbD8/ALoorYEAxx8sY+cJliRz3WZ5qclh8KdTzV6apB3mBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049458; h=DMARC-Filter:DKIM-Signature: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=CMBHCfO48rJnJSzhEgb16LkkE465o2nqbFsGiuVt1bQ=; b=HcC45tfvND/vxaTPcV0g9MYhsLx2Jqf+jTWM2yssYlOxj4PBznI01fZMkZIN+QaAARaZ 9CbxFn81ARHCs5WtuN9TxbGVGp9kJD+RJPh7jIzWtTM/PxAMfhJj/9crytdPOay4M91G+ VIQqB16yJzJlSapmCwb4r/1vw3PWB2tqICULtrYns7yY9vtOqjJmeKOW8p6y4madzI6L6 FNvzJFCiDd75TvyDt7LhHcHnyCqfJAoZuK1HxQIkcCk9FRAmC7I8h3NNjFU6j3zqrOouf whrca4RZBupdWbu4+noaAjZwnjJQpuY9v6QatAjcSNOmzCtqguT8F8xtsgUEghisYFA== 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=RxHxC2jX; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 51056606A33A for ; Mon, 30 Nov 2026 14:37:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 51056606A33A 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=RxHxC2jX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796049455; 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=CMBHCfO48rJnJSzhEgb16LkkE465o2nqbFsGiuVt1bQ=; b=RxHxC2jXQMznTxEPYqzvMhIOswV45VNoSHKiWx+Tk/WYlt7gmVT5wbBjvbPhIYpJlukTJt kM4Q/yTYIMzSvzLe7rFXjgFnil6FXpYJXzleJf3E2Vty9WFud6vR/BZT6ANexxh81CeVLG +WnhHeyYLAqMziLm02hhJCbYFpGAIgw= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-W2Yj6fjPOkaq5IwewjiZIA-1; Mon, 30 Nov 2026 14:37:33 +0000 X-MC-Unique: W2Yj6fjPOkaq5IwewjiZIA-1 X-Mimecast-MFC-AGG-ID: W2Yj6fjPOkaq5IwewjiZIA_1796049452 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4a7c864000eso6218109f8f.0 for ; Mon, 30 Nov 2026 06:37:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796049452; x=1796654252; 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=CMBHCfO48rJnJSzhEgb16LkkE465o2nqbFsGiuVt1bQ=; b=lgWpZvJPpSiz6DwUKE8tWuXwQkYlfnhQcgYiB2cfTqZ3f5XafgCVqOnrtlFX40aEvT t6wYbY+DHZ1UvpBCB6JZnDJL58A1FSU5EQ827TH0fsr/r4ZNy5me6omR1N4SKgPgt3U4 UWQ57D8nvMIdMNCPVPh1432/FkZ9Adiqcg4O5M22Wfh2nWpxhd1QSQ/6z4oVkfr7aEkH R1Xaaaysow+QcD3oWeTk/k9uQLAAnykQqbHGoe5ncFt1dt3+tCZ+YVqcpAzNyzDYw+Q6 +LwTa6VGvxgmvfUB8kOSlKVYdZijKNl1Ri531LUG5hg/SnSHztcg65tYTX2W8L+vyr/p SNjQ== X-Forwarded-Encrypted: i=1; AL+hErF+YYMgZzU4o6Y7Uhgk4E0dNuwyM0RvKmtXi4pjnbk7nHyzhJrTCWqkcwzqPoOFilenS+gqrhNctlpk5cP/jw==@lists.linux.dev X-Gm-Message-State: APuU4Z9m18iffj1dArtiloX5mLg2ccxy7zveiygn2/iajag1SbkqF9AI npY9C9rj7eWnxE03KXe6dGv5uVUyJW6KfjVl6+q9uBh35jfH0YUN0tKgj+MvjlGj0fY7xgkzE5E cCpY4qKeCpmhmYnUNtt3FLw0ETTxEVqdMzmRUppb6hpwQ5jN4Ds1EqyWDzgoHSqxlVvhzGm3DYL 7w X-Gm-Gg: AZFdTZe4E6H7xFk3qF1v5HkYeDT7/fbtXTifcfWpYCgDBf14YA/hSFHz5/yhaA8ZzfF MMzRPAQeG/u70lhGrGyBzKvV6xrL4RkBJ5kBarwrcV6GzH7Rbi688ZbFpCkor+IiiQ3vvAaHhVK W3fJCmRd8z/WehSvkuw3snuZnYBEYQbirCsyxzKbbwJtdCgMeeli4xgJujkfF9A5/QsVslhHrVj 4auDFfaUNhtwsDRehVGJ0Paj4dSvolXtBvt2T+vg5wyv91tvgZ7vgEFkXP6GQSJtyt3ExcbLH+K 8iuUVQhHBDQRV/LKkMPDgcDPa2hJGrVNrGxTgkL5/qGpZK2dnUpNUn6xilY7fCVR2rqCLxVFKNU l2gKwWuKZttuIN5vZwtP+olcG+1GknnSRZevucmtS+VN7F4DuFxUaYxfXo2Xv+efXUpVMs32bc0 pPvyb1Y+BOfJHmLw51rmJEKguyUQyW5wnhfPKk6ynF X-Received: by 2002:a05:6000:2c04:b0:48e:7470:9e98 with SMTP id ffacd0b85a97d-4abb683b5edmr74648874f8f.39.1796049452166; Mon, 30 Nov 2026 06:37:32 -0800 (PST) X-Received: by 2002:a05:6000:2c04:b0:48e:7470:9e98 with SMTP id ffacd0b85a97d-4abb683b5edmr74648808f8f.39.1796049451650; Mon, 30 Nov 2026 06:37:31 -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-4ab6b110c3csm62452044f8f.36.2026.11.30.06.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 06:37:31 -0800 (PST) From: Miklos Szeredi To: fuse-devel@lists.linux.dev, virtualization@lists.linux.dev Cc: Li Wang , German Maglione , Stefan Hajnoczi Subject: [PATCH v2 2/4] virtiofs: don't abort DAX removemapping on allocation failure Date: Mon, 30 Nov 2026 15:37:18 +0100 Message-ID: <20261130143728.326871-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130143728.326871-1-mszeredi@redhat.com> References: <20261130143728.326871-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: 8mb9ul-ZP-pUlAnEvuvTP_D3FE3w78Au5cU2jMH49mk_1796049452 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") 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..c5bbb5d91026 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) { + /* + * The ranges are not reusable until the server has dropped + * the mappings, and the request is never retried, so failing + * here would take them out of use for good. Fall back to + * removing them one at a time, which needs no allocation; + * slow, but this only happens under memory pressure. + */ + 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