From: "Darrick J. Wong" <djwong@kernel.org>
To: aalbersh@kernel.org, djwong@kernel.org, cem@kernel.org
Cc: Christoph Hellwig <hch@lst.de>, linux-xfs@vger.kernel.org
Subject: [PATCH 25/64] xfs: create libxfs helper to link a new inode into a directory
Date: Tue, 01 Oct 2024 18:14:20 -0700 [thread overview]
Message-ID: <172783102158.4036371.4553530797356384848.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <172783101710.4036371.10020616537589726441.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
Source kernel commit: 1fa2e81957cf11620867729fb613b121692ee0d3
Create a new libxfs function to link a newly created inode into a
directory. The upcoming metadata directory feature will need this to
create a metadata directory tree.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
libxfs/xfs_dir2.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
libxfs/xfs_dir2.h | 12 ++++++++++++
2 files changed, 65 insertions(+)
diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c
index 9cf05ec51..e98b28024 100644
--- a/libxfs/xfs_dir2.c
+++ b/libxfs/xfs_dir2.c
@@ -18,6 +18,9 @@
#include "xfs_errortag.h"
#include "xfs_trace.h"
#include "xfs_health.h"
+#include "xfs_bmap_btree.h"
+#include "xfs_trans_space.h"
+#include "xfs_parent.h"
const struct xfs_name xfs_name_dotdot = {
.name = (const unsigned char *)"..",
@@ -755,3 +758,53 @@ xfs_dir2_compname(
return xfs_ascii_ci_compname(args, name, len);
return xfs_da_compname(args, name, len);
}
+
+/*
+ * Given a directory @dp, a newly allocated inode @ip, and a @name, link @ip
+ * into @dp under the given @name. If @ip is a directory, it will be
+ * initialized. Both inodes must have the ILOCK held and the transaction must
+ * have sufficient blocks reserved.
+ */
+int
+xfs_dir_create_child(
+ struct xfs_trans *tp,
+ unsigned int resblks,
+ struct xfs_dir_update *du)
+{
+ struct xfs_inode *dp = du->dp;
+ const struct xfs_name *name = du->name;
+ struct xfs_inode *ip = du->ip;
+ int error;
+
+ xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
+ xfs_assert_ilocked(dp, XFS_ILOCK_EXCL);
+
+ error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks);
+ if (error) {
+ ASSERT(error != -ENOSPC);
+ return error;
+ }
+
+ xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
+ xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
+
+ if (S_ISDIR(VFS_I(ip)->i_mode)) {
+ error = xfs_dir_init(tp, ip, dp);
+ if (error)
+ return error;
+
+ xfs_bumplink(tp, dp);
+ }
+
+ /*
+ * If we have parent pointers, we need to add the attribute containing
+ * the parent information now.
+ */
+ if (du->ppargs) {
+ error = xfs_parent_addname(tp, du->ppargs, dp, name, ip);
+ if (error)
+ return error;
+ }
+
+ return 0;
+}
diff --git a/libxfs/xfs_dir2.h b/libxfs/xfs_dir2.h
index 6dbe6e9ec..a1ba6fd0a 100644
--- a/libxfs/xfs_dir2.h
+++ b/libxfs/xfs_dir2.h
@@ -309,4 +309,16 @@ static inline unsigned char xfs_ascii_ci_xfrm(unsigned char c)
return c;
}
+struct xfs_parent_args;
+
+struct xfs_dir_update {
+ struct xfs_inode *dp;
+ const struct xfs_name *name;
+ struct xfs_inode *ip;
+ struct xfs_parent_args *ppargs;
+};
+
+int xfs_dir_create_child(struct xfs_trans *tp, unsigned int resblks,
+ struct xfs_dir_update *du);
+
#endif /* __XFS_DIR2_H__ */
next prev parent reply other threads:[~2024-10-02 1:14 UTC|newest]
Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 1:00 [PATCHBOMB] xfsprogs: catch us up to 6.11 Darrick J. Wong
2024-10-02 1:04 ` [PATCHSET 1/6] xfsprogs: Debian and Ubuntu archive changes Darrick J. Wong
2024-10-02 1:05 ` [PATCH 1/6] debian: Update debhelper-compat level Darrick J. Wong
2024-10-02 1:06 ` [PATCH 2/6] debian: Update public release key Darrick J. Wong
2024-10-02 1:06 ` [PATCH 3/6] debian: Prevent recreating the orig tarball Darrick J. Wong
2024-10-02 1:06 ` [PATCH 4/6] debian: Add Build-Depends on pkg with systemd.pc Darrick J. Wong
2024-10-02 1:07 ` [PATCH 5/6] debian: Modernize build script Darrick J. Wong
2024-10-02 1:07 ` [PATCH 6/6] debian: Correct the day-of-week on 2024-09-04 Darrick J. Wong
2024-10-02 5:47 ` [PATCHSET 1/6] xfsprogs: Debian and Ubuntu archive changes Christoph Hellwig
2024-10-02 1:04 ` [PATCHSET 2/6] xfsprogs: do not depend on libattr Darrick J. Wong
2024-10-02 1:07 ` [PATCH 1/2] misc: clean up code around attr_list_by_handle calls Darrick J. Wong
2024-10-02 1:07 ` [PATCH 2/2] libfrog: emulate deprecated attrlist functionality in libattr Darrick J. Wong
2024-10-02 1:04 ` [PATCHSET v2.5 3/6] libxfs: resync with 6.11 Darrick J. Wong
2024-10-02 1:08 ` [PATCH 01/64] xfs: avoid redundant AGFL buffer invalidation Darrick J. Wong
2024-10-02 1:08 ` [PATCH 02/64] xfs: don't walk off the end of a directory data block Darrick J. Wong
2024-10-02 1:08 ` [PATCH 03/64] xfs: Remove header files which are included more than once Darrick J. Wong
2024-10-02 1:08 ` [PATCH 04/64] xfs: hoist extent size helpers to libxfs Darrick J. Wong
2024-10-02 1:09 ` [PATCH 05/64] xfs: hoist inode flag conversion functions " Darrick J. Wong
2024-10-02 1:09 ` [PATCH 06/64] xfs: hoist project id get/set " Darrick J. Wong
2024-10-02 1:09 ` [PATCH 07/64] libxfs: put all the inode functions in a single file Darrick J. Wong
2024-10-02 1:09 ` [PATCH 08/64] libxfs: pass IGET flags through to xfs_iread Darrick J. Wong
2024-10-02 5:47 ` Christoph Hellwig
2024-10-02 1:10 ` [PATCH 09/64] xfs: pack icreate initialization parameters into a separate structure Darrick J. Wong
2024-10-02 1:10 ` [PATCH 10/64] libxfs: " Darrick J. Wong
2024-10-02 1:10 ` [PATCH 11/64] xfs: implement atime updates in xfs_trans_ichgtime Darrick J. Wong
2024-10-02 1:10 ` [PATCH 12/64] libxfs: rearrange libxfs_trans_ichgtime call when creating inodes Darrick J. Wong
2024-10-02 5:48 ` Christoph Hellwig
2024-10-02 1:11 ` [PATCH 13/64] libxfs: set access time when creating files Darrick J. Wong
2024-10-02 5:49 ` Christoph Hellwig
2024-10-02 1:11 ` [PATCH 14/64] libxfs: when creating a file in a directory, set the project id based on the parent Darrick J. Wong
2024-10-02 5:49 ` Christoph Hellwig
2024-10-02 1:11 ` [PATCH 15/64] libxfs: pass flags2 from parent to child when creating files Darrick J. Wong
2024-10-02 5:49 ` Christoph Hellwig
2024-10-02 1:12 ` [PATCH 16/64] xfs: split new inode creation into two pieces Darrick J. Wong
2024-10-02 1:12 ` [PATCH 17/64] libxfs: " Darrick J. Wong
2024-10-02 1:12 ` [PATCH 18/64] libxfs: backport inode init code from the kernel Darrick J. Wong
2024-10-02 5:50 ` Christoph Hellwig
2024-10-02 1:12 ` [PATCH 19/64] libxfs: remove libxfs_dir_ialloc Darrick J. Wong
2024-10-02 5:51 ` Christoph Hellwig
2024-10-02 1:13 ` [PATCH 20/64] libxfs: implement get_random_u32 Darrick J. Wong
2024-10-02 5:51 ` Christoph Hellwig
2024-10-02 1:13 ` [PATCH 21/64] xfs: hoist new inode initialization functions to libxfs Darrick J. Wong
2024-10-02 1:13 ` [PATCH 22/64] xfs: hoist xfs_iunlink " Darrick J. Wong
2024-10-02 1:13 ` [PATCH 23/64] xfs: hoist xfs_{bump,drop}link " Darrick J. Wong
2024-10-02 1:14 ` [PATCH 24/64] xfs: separate the icreate logic around INIT_XATTRS Darrick J. Wong
2024-10-02 1:14 ` Darrick J. Wong [this message]
2024-10-02 1:14 ` [PATCH 26/64] xfs: create libxfs helper to link an existing inode into a directory Darrick J. Wong
2024-10-02 1:14 ` [PATCH 27/64] xfs: hoist inode free function to libxfs Darrick J. Wong
2024-10-02 1:15 ` [PATCH 28/64] xfs: create libxfs helper to remove an existing inode/name from a directory Darrick J. Wong
2024-10-02 1:15 ` [PATCH 29/64] xfs: create libxfs helper to exchange two directory entries Darrick J. Wong
2024-10-02 1:15 ` [PATCH 30/64] xfs: create libxfs helper to rename " Darrick J. Wong
2024-10-02 1:15 ` [PATCH 31/64] xfs: move dirent update hooks to xfs_dir2.c Darrick J. Wong
2024-10-02 1:16 ` [PATCH 32/64] xfs: don't use the incore struct xfs_sb for offsets into struct xfs_dsb Darrick J. Wong
2024-10-02 1:16 ` [PATCH 33/64] xfs: clean up extent free log intent item tracepoint callsites Darrick J. Wong
2024-10-02 1:16 ` [PATCH 34/64] xfs: convert "skip_discard" to a proper flags bitset Darrick J. Wong
2024-10-02 1:16 ` [PATCH 35/64] xfs: pass the fsbno to xfs_perag_intent_get Darrick J. Wong
2024-10-02 1:17 ` [PATCH 36/64] xfs: add a xefi_entry helper Darrick J. Wong
2024-10-02 1:17 ` [PATCH 37/64] xfs: reuse xfs_extent_free_cancel_item Darrick J. Wong
2024-10-02 1:17 ` [PATCH 38/64] xfs: remove duplicate asserts in xfs_defer_extent_free Darrick J. Wong
2024-10-02 1:17 ` [PATCH 39/64] xfs: remove xfs_defer_agfl_block Darrick J. Wong
2024-10-02 1:18 ` [PATCH 40/64] xfs: move xfs_extent_free_defer_add to xfs_extfree_item.c Darrick J. Wong
2024-10-02 1:18 ` [PATCH 41/64] xfs: give rmap btree cursor error tracepoints their own class Darrick J. Wong
2024-10-02 1:18 ` [PATCH 42/64] xfs: pass btree cursors to rmap btree tracepoints Darrick J. Wong
2024-10-02 1:19 ` [PATCH 43/64] xfs: clean up rmap log intent item tracepoint callsites Darrick J. Wong
2024-10-02 1:19 ` [PATCH 44/64] xfs: add a ri_entry helper Darrick J. Wong
2024-10-02 1:19 ` [PATCH 45/64] xfs: reuse xfs_rmap_update_cancel_item Darrick J. Wong
2024-10-02 1:19 ` [PATCH 46/64] xfs: don't bother calling xfs_rmap_finish_one_cleanup in xfs_rmap_finish_one Darrick J. Wong
2024-10-02 1:20 ` [PATCH 47/64] xfs: simplify usage of the rcur local variable " Darrick J. Wong
2024-10-02 1:20 ` [PATCH 48/64] xfs: move xfs_rmap_update_defer_add to xfs_rmap_item.c Darrick J. Wong
2024-10-02 1:20 ` [PATCH 49/64] xfs: give refcount btree cursor error tracepoints their own class Darrick J. Wong
2024-10-02 1:20 ` [PATCH 50/64] xfs: create specialized classes for refcount tracepoints Darrick J. Wong
2024-10-02 1:21 ` [PATCH 51/64] xfs: pass btree cursors to refcount btree tracepoints Darrick J. Wong
2024-10-02 1:21 ` [PATCH 52/64] xfs: clean up refcount log intent item tracepoint callsites Darrick J. Wong
2024-10-02 1:21 ` [PATCH 53/64] xfs: add a ci_entry helper Darrick J. Wong
2024-10-02 1:21 ` [PATCH 54/64] xfs: reuse xfs_refcount_update_cancel_item Darrick J. Wong
2024-10-02 1:22 ` [PATCH 55/64] xfs: don't bother calling xfs_refcount_finish_one_cleanup in xfs_refcount_finish_one Darrick J. Wong
2024-10-02 1:22 ` [PATCH 56/64] xfs: simplify usage of the rcur local variable " Darrick J. Wong
2024-10-02 1:22 ` [PATCH 57/64] xfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c Darrick J. Wong
2024-10-02 1:22 ` [PATCH 58/64] xfs: Avoid races with cnt_btree lastrec updates Darrick J. Wong
2024-10-02 1:23 ` [PATCH 59/64] xfs: AIL doesn't need manual pushing Darrick J. Wong
2024-10-02 1:23 ` [PATCH 60/64] xfs: background AIL push should target physical space Darrick J. Wong
2024-10-02 1:23 ` [PATCH 61/64] xfs: get rid of xfs_ag_resv_rmapbt_alloc Darrick J. Wong
2024-10-02 1:23 ` [PATCH 62/64] xfs: remove unused parameter in macro XFS_DQUOT_LOGRES Darrick J. Wong
2024-10-02 1:24 ` [PATCH 63/64] xfs: fix di_onlink checking for V1/V2 inodes Darrick J. Wong
2024-10-02 1:24 ` [PATCH 64/64] xfs: xfs_finobt_count_blocks() walks the wrong btree Darrick J. Wong
2024-10-02 1:05 ` [PATCHSET v2.5 4/6] xfsprogs: port tools to new 6.11 APIs Darrick J. Wong
2024-10-02 1:24 ` [PATCH 1/4] xfs_db: port the unlink command to use libxfs_droplink Darrick J. Wong
2024-10-02 5:52 ` Christoph Hellwig
2024-10-02 1:25 ` [PATCH 2/4] xfs_db/mkfs/xfs_repair: port to use XFS_ICREATE_UNLINKABLE Darrick J. Wong
2024-10-02 5:53 ` Christoph Hellwig
2024-10-02 22:50 ` Darrick J. Wong
2024-10-04 11:08 ` Andrey Albershteyn
2024-10-02 1:25 ` [PATCH 3/4] xfs_db/mdrestore/repair: don't use the incore struct xfs_sb for offsets into struct xfs_dsb Darrick J. Wong
2024-10-02 5:54 ` Christoph Hellwig
2024-10-02 22:51 ` Darrick J. Wong
2024-10-02 1:25 ` [PATCH 4/4] xfs_db: port the iunlink command to use the libxfs iunlink function Darrick J. Wong
2024-10-02 5:54 ` Christoph Hellwig
2024-10-02 1:05 ` [PATCHSET 5/6] xfs_repair: cleanups for 6.11 Darrick J. Wong
2024-10-02 1:25 ` [PATCH 1/4] xfs_repair: fix exchrange upgrade Darrick J. Wong
2024-10-02 5:57 ` Christoph Hellwig
2024-10-02 1:26 ` [PATCH 2/4] xfs_repair: don't crash in get_inode_parent Darrick J. Wong
2024-10-02 5:58 ` Christoph Hellwig
2024-10-02 1:26 ` [PATCH 3/4] xfs_repair: use library functions to reset root/rbm/rsum inodes Darrick J. Wong
2024-10-02 5:58 ` Christoph Hellwig
2024-10-02 1:26 ` [PATCH 4/4] xfs_repair: use library functions for orphanage creation Darrick J. Wong
2024-10-02 5:58 ` Christoph Hellwig
2024-10-02 1:05 ` [PATCHSET v2.5 6/6] mkfs: clean up inode initialization code Darrick J. Wong
2024-10-02 1:26 ` [PATCH 1/2] mkfs: clean up the rtinit() function Darrick J. Wong
2024-10-02 6:03 ` Christoph Hellwig
2024-10-02 1:27 ` [PATCH 2/2] mkfs: break up the rest of " Darrick J. Wong
2024-10-02 6:04 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=172783102158.4036371.4553530797356384848.stgit@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox