Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp149600lqb; Tue, 28 May 2024 11:16:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPsGE8U2Ogs0uC5lppPdFjg38DUT7pvofL27/JL/CwEr1KL9pWr5Gq/tm0FKOv+VvAx40EKjAle6NZaE7rZzO49evrhOUoS+Wnqo30uQ== X-Google-Smtp-Source: AGHT+IEkH7KSihVH3HKG5zwKEcR1ceW/g+FjPmEbvsyE+Po4fmfCXFyIPpSY05V3wsBlyKJTWIJx X-Received: by 2002:a17:902:d2cd:b0:1f4:5685:b146 with SMTP id d9443c01a7336-1f45685b4c7mr143615785ad.37.1716920166435; Tue, 28 May 2024 11:16:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716920166; cv=pass; d=google.com; s=arc-20160816; b=JMHqj7Blrm5EtIXBsYblM2VZlAG3mJnwHUBt06u9T2bn4es8nkJLgT4EwsD02716jq Mhe9FeRhp8eQDKJbUChR3cPG6R3eTNTiuzpwUHLMh9QmqfOLrAOSoJ3XrFr5ZQ0Qls4M 9tOqjGkG6cGXbQ9RfkkKGl89MkP91Op5mrKrhcvK0mH4MeQ/Jx9aGQI/tE2CTHwNM0iR itjjX+qRvZICMXtmBIE/YBqcVlLJWQZYmBZCoNhDUoqFCKEdlIvmyty7mku2uNsZS9g2 9vxnnjtczMzOy/dKwAkK+l+Ya07/SgRHGIXbR7Nh7F0tZnr3adCtTaEndLV5QT28ZTzh BOMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+R2mjNBAIE/TqRuotFDeDo18cL36mswtB3So/eMZdyk=; fh=NxsD1VXGtxX7D22HWBE72S/UAWD4f4gSJFrLKKCXY/E=; b=F547X5HlqQTJnIQ80UrYd9VRkE3UiLMB6XOuQpcXCBlVsyAdGhpNXJ/Xw+NIIavP64 KUkSujEHwT7reWiuQffOUNQA44dYGNjP7Rzx75PfWIK3i72KdxtKrTMRs/LFH8Xi9JLV OeoEtRlIMQB8VqO25nDsgJNNEI3xWIno0+OJAdxw47SeGX2GZZy2Xx+cHgcn5rAn435n 7sxjwkuhjBt0lCqFEe/1zWvAF8i5gLlRNQo6edkgLVWG920s1dkjYHXtA1Q4ERbPUQdA UXBkiQYFnN6efmIj8BEmvRmsb/kym0NagOQd/zHxEHE1q0kuRYreAKfl/VdAQHMbXcdH /jTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Xf1WvXMv; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-ext4+bounces-2671-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2671-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c96fc7csi81240255ad.282.2024.05.28.11.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 11:16:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2671-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Xf1WvXMv; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-ext4+bounces-2671-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2671-linux.lists.archive=gmail.com@vger.kernel.org" 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 066D7286745 for ; Tue, 28 May 2024 16:48:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F482174ECD; Tue, 28 May 2024 16:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Xf1WvXMv" X-Original-To: linux-ext4@vger.kernel.org Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 446D9173324; Tue, 28 May 2024 16:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716914914; cv=none; b=q7iSKLilaAFU4KNR36uzm/JqrWcWHxUauaFovXdw1uhJmzRHZIcm8WUHh+Xq2hMsn7y6hQKfd/7LLhWK638pHy/V9lK3ZzE/kKjM9IteuCbLAVw8/11GlzElEF6ibGwhJsvyI1oYjq9uiUJByIRHi+Q0SYrppWdW/hTBcKCSGIU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716914914; c=relaxed/simple; bh=ZCJeakTcJ6p69GvYR2jMvA2yFZ2ccNHLw/EMpWoY354=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FrODt33zE5XnYcxgUaE5ia3Mtp3/WTHCnpH1kgS7b5Qau407/QJX79C/j7E/a97ZNsY3o12Bt85mvQEC1qqf2qaHS94yG4qhL805BmmUqPcNNOiX3EkpDc+Njzgoeml3MYt+SKlwv/9FFHIuHuTJftvgUlzh+GfFDvQ1lau29Dg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Xf1WvXMv; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=+R2mjNBAIE/TqRuotFDeDo18cL36mswtB3So/eMZdyk=; b=Xf1WvXMvl5WlVX8u0ljEDCV5So uItvkVqBDJLPub2s/K4y487zJ4rn+Z4P48WTZRTL6e876elM3+diD72CEGB4yK0hvCZSVoNSWO76u 3TJJYaRWItJ2InVUFt1swNPhcgMvBS43fDG5fxqcKjqHJUxXMWHAvFdeJPFCUPGulkhlSZK1Dr2GY Y9UOcdOE0a6KEIx4/BF41ksKTAW4HAE7+eqOnFBMh28U88q5Mer/Dyd0DCht6KzGP0OJ1w1dCVBcJ huYVfcq4G7+Q+ICGYrp3snMztABD31qRrkNcxS3Drjbh9QCr1Sm24PvY79ksTP9j9M57XVNARVvRA +nr27XNg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBzzz-00000008pjL-2Mcf; Tue, 28 May 2024 16:48:31 +0000 From: "Matthew Wilcox (Oracle)" To: Christoph Hellwig Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org Subject: [PATCH 4/7] fs: Add filemap_symlink() Date: Tue, 28 May 2024 17:48:25 +0100 Message-ID: <20240528164829.2105447-5-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240528164829.2105447-1-willy@infradead.org> References: <20240528164829.2105447-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is the equivalent of page_symlink() but takes a buffered_write_operations structure. It also doesn't handle GFP_NOFS for you; if you need that, use memalloc_nofs_save() yourself. Signed-off-by: Matthew Wilcox (Oracle) --- fs/namei.c | 25 +++++++++++++++++++++++++ include/linux/pagemap.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index 37fb0a8aa09a..4352206b0408 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -5255,6 +5255,31 @@ int page_symlink(struct inode *inode, const char *symname, int len) } EXPORT_SYMBOL(page_symlink); +int filemap_symlink(struct inode *inode, const char *symname, int len, + const struct buffered_write_operations *ops, void **fsdata) +{ + struct address_space *mapping = inode->i_mapping; + struct folio *folio; + int err; + +retry: + folio = ops->write_begin(NULL, mapping, 0, len-1, fsdata); + if (IS_ERR(folio)) + return PTR_ERR(folio); + + memcpy(folio_address(folio), symname, len-1); + + err = ops->write_end(NULL, mapping, 0, len-1, len-1, folio, fsdata); + if (err < 0) + return err; + if (err < len-1) + goto retry; + + mark_inode_dirty(inode); + return 0; +} +EXPORT_SYMBOL(filemap_symlink); + const struct inode_operations page_symlink_inode_operations = { .get_link = page_get_link, }; diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 2921c1cc6335..a7540f757368 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -39,6 +39,8 @@ ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); #define __generic_file_write_iter(kiocb, iter) \ __filemap_write_iter(kiocb, iter, NULL, NULL) +int filemap_symlink(struct inode *inode, const char *symname, int len, + const struct buffered_write_operations *bw, void **fsdata); unsigned long invalidate_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t end); -- 2.43.0