From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 18/19] libgfs2: Create jindex directory separately from journals
Date: Tue, 2 Sep 2014 13:07:35 +0100 [thread overview]
Message-ID: <1409659656-23051-19-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1409659656-23051-1-git-send-email-anprice@redhat.com>
Previously journals were created indirectly via build_jindex and the
jindex inode (and therefore the master inode) was created before the
journals. Now that we're allocating the journals in whole resource
groups at the start of the mkfs process we need a way to create the
jindex after the journals are created. This adds lgfs2_build_jindex
which takes a list of inums relating to journals and builds the jindex
from them.
The old build_jindex function is left in place until the other tools
have been switched to use the new function.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/libgfs2/libgfs2.h | 1 +
gfs2/libgfs2/structures.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 406fbbe..831d45b 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -729,6 +729,7 @@ extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize
extern int build_journal(struct gfs2_sbd *sdp, int j,
struct gfs2_inode *jindex);
extern int build_jindex(struct gfs2_sbd *sdp);
+extern int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t nmemb);
extern int build_per_node(struct gfs2_sbd *sdp);
extern int build_inum(struct gfs2_sbd *sdp);
extern int build_statfs(struct gfs2_sbd *sdp);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index c4b9ebc..87ffde7 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -255,6 +255,46 @@ int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex)
return ret;
}
+/**
+ * Write a jindex file given a list of journal inums.
+ * master: Inode of the master directory
+ * jnls: List of inum structures relating to previously created journals.
+ * nmemb: The number of entries in the list (number of journals).
+ * Returns 0 on success or non-zero on error with errno set.
+ */
+int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t nmemb)
+{
+ char fname[GFS2_FNAMESIZE + 1];
+ struct gfs2_inode *jindex;
+ unsigned j;
+ int ret;
+
+ if (nmemb == 0 || jnls == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ jindex = createi(master, "jindex", S_IFDIR | 0700, GFS2_DIF_SYSTEM);
+ if (jindex == NULL)
+ return 1;
+
+ fname[GFS2_FNAMESIZE] = '\0';
+
+ for (j = 0; j < nmemb; j++) {
+ snprintf(fname, GFS2_FNAMESIZE, "journal%u", j);
+ ret = dir_add(jindex, fname, strlen(fname), &jnls[j], IF2DT(S_IFREG | 0600));
+ if (ret)
+ return 1;
+ }
+
+ if (cfg_debug) {
+ printf("\nJindex:\n");
+ gfs2_dinode_print(&jindex->i_di);
+ }
+
+ inode_put(&jindex);
+ return 0;
+}
+
int build_jindex(struct gfs2_sbd *sdp)
{
struct gfs2_inode *jindex;
--
1.9.3
next prev parent reply other threads:[~2014-09-02 12:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 12:07 [Cluster-devel] [PATCH 00/19] gfs2-utils: Introduce extent allocation and speed up journal creation Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 01/19] libgfs2: Keep a pointer to the sbd in lgfs2_rgrps_t Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 02/19] libgfs2: Move bitmap buffers inside struct gfs2_bitmap Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 03/19] libgfs2: Fix an impossible loop condition in gfs2_rgrp_read Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 04/19] libgfs2: Introduce struct lgfs2_rbm Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 05/19] libgfs2: Move struct _lgfs2_rgrps into rgrp.h Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 06/19] libgfs2: Add functions for finding free extents Andrew Price
2014-09-03 10:17 ` Steven Whitehouse
2014-09-03 12:13 ` Andrew Price
2014-09-03 12:24 ` Steven Whitehouse
2014-09-02 12:07 ` [Cluster-devel] [PATCH 07/19] tests: Add unit tests for the new extent search functions Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 08/19] libgfs2: Ignore an empty rgrp plan if a length is specified Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 09/19] libgfs2: Add back-pointer to rgrps in lgfs2_rgrp_t Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 10/19] libgfs2: Const-ify the parameters of print functions Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 11/19] libgfs2: Allow init_dinode to accept a preallocated bh Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 12/19] libgfs2: Add extent allocation functions Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 13/19] libgfs2: Add support for allocating entire rgrp headers Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 14/19] libgfs2: Write file metadata sequentially Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 15/19] libgfs2: Fix alignment in lgfs2_rgsize_for_data Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 16/19] libgfs2: Handle non-zero bitmaps in lgfs2_rgrp_write Andrew Price
2014-09-02 12:07 ` [Cluster-devel] [PATCH 17/19] libgfs2: Add a speedier journal data block writing function Andrew Price
2014-09-02 12:07 ` Andrew Price [this message]
2014-09-02 12:07 ` [Cluster-devel] [PATCH 19/19] mkfs.gfs2: Improve journal creation performance Andrew Price
2014-09-02 14:06 ` [Cluster-devel] [PATCH 00/19] gfs2-utils: Introduce extent allocation and speed up journal creation Bob Peterson
2014-09-03 10:20 ` Steven Whitehouse
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=1409659656-23051-19-git-send-email-anprice@redhat.com \
--to=anprice@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).