From: Andreas Dilger <adilger@sun.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH] allow goal inode to be specified
Date: Wed, 10 Jun 2009 14:27:02 -0600 [thread overview]
Message-ID: <20090610202702.GI9002@webber.adilger.int> (raw)
Allow a goal inode to be specified when allocating new inodes.
If the goal is within the range of valid inodes use this in
preference to one of the other target inode heuristics (Orlov or
parent directory).
The goal inode can be specified via /sys/fs/{dev}/inode_goal for
testing inode allocation beyond 2^32 blocks on very large filesystems,
and in the future will be used for large xattr inode allocation.
Signed-off-by: Andreas Dilger <adilger@sun.com>
Index: linux-stage/fs/ext4/ialloc.c
===================================================================
--- linux-stage.orig/fs/ext4/ialloc.c
+++ linux-stage/fs/ext4/ialloc.c
@@ -675,7 +675,8 @@ err_ret:
* For other inodes, search forward from the parent directory's block
* group to find a free inode.
*/
-struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
+struct inode *ext4_new_inode_goal(handle_t *handle, struct inode *dir,
+ int mode, unsigned goal)
{
struct super_block *sb;
struct buffer_head *inode_bitmap_bh = NULL;
@@ -706,6 +707,14 @@ struct inode *ext4_new_inode(handle_t *h
sbi = EXT4_SB(sb);
es = sbi->s_es;
+ if (goal && goal < le32_to_cpu(es->s_inodes_count)) {
+ group = (goal - 1) / EXT4_INODES_PER_GROUP(sb);
+ ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb);
+
+ ret2 = 0;
+ goto got_group;
+ }
+
if (sbi->s_log_groups_per_flex && test_opt(sb, OLDALLOC)) {
ret2 = find_group_flex(sb, dir, &group);
if (ret2 == -1) {
@@ -724,7 +733,7 @@ got_group:
if (ret2 == -1)
goto out;
- for (i = 0; i < sbi->s_groups_count; i++) {
+ for (i = 0; i < sbi->s_groups_count; i++, ino = 0) {
err = -EIO;
gdp = ext4_get_group_desc(sb, group, &group_desc_bh);
@@ -736,8 +745,6 @@ got_group:
if (!inode_bitmap_bh)
goto fail;
- ino = 0;
-
repeat_in_this_group:
ino = ext4_find_next_zero_bit((unsigned long *)
inode_bitmap_bh->b_data,
Index: linux-stage/fs/ext4/ext4.h
===================================================================
--- linux-stage.orig/fs/ext4/ext4.h
+++ linux-stage/fs/ext4/ext4.h
@@ -1032,7 +1032,14 @@ extern int ext4fs_dirhash(const char *na
dx_hash_info *hinfo);
/* ialloc.c */
-extern struct inode * ext4_new_inode(handle_t *, struct inode *, int);
+extern struct inode *ext4_new_inode_goal(handle_t *handle, struct inode *dir,
+ int mode, unsigned goal);
+static inline struct inode *ext4_new_inode(handle_t *handle, struct inode *dir,
+ int mode)
+{
+ return ext4_new_inode_goal(handle, dir, mode,
+ EXT4_SB(dir->i_sb)->s_inode_goal);
+}
extern void ext4_free_inode(handle_t *, struct inode *);
extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
extern unsigned long ext4_count_free_inodes(struct super_block *);
Index: linux-stage/fs/ext4/super.c
===================================================================
--- linux-stage.orig/fs/ext4/super.c
+++ linux-stage/fs/ext4/super.c
@@ -2145,6 +2145,7 @@
EXT4_RO_ATTR(lifetime_write_kbytes);
EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show,
inode_readahead_blks_store, s_inode_readahead_blks);
+EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
@@ -2157,6 +2158,7 @@
ATTR_LIST(session_write_kbytes),
ATTR_LIST(lifetime_write_kbytes),
ATTR_LIST(inode_readahead_blks),
+ ATTR_LIST(inode_goal),
ATTR_LIST(mb_stats),
ATTR_LIST(mb_max_to_scan),
ATTR_LIST(mb_min_to_scan),
Index: linux-stage/fs/ext4/ext4_sb.h
===================================================================
--- linux-stage.orig/fs/ext4/ext4_sb.h
+++ linux-stage/fs/ext4/ext4_sb.h
@@ -53,6 +53,7 @@ struct ext4_sb_info {
int s_inode_size;
int s_first_ino;
unsigned int s_inode_readahead_blks;
+ unsigned int s_inode_goal;
spinlock_t s_next_gen_lock;
u32 s_next_generation;
u32 s_hash_seed[4];
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
next reply other threads:[~2009-06-10 20:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-10 20:27 Andreas Dilger [this message]
2009-06-13 15:48 ` [PATCH] allow goal inode to be specified Theodore Tso
2009-06-13 16:33 ` [PATCH 1/2] ext4: Use a hash of the topdir directory name for the Orlov parent group Theodore Ts'o
2009-06-13 16:33 ` [PATCH 2/2] ext4: teach the inode allocator to use a goal inode number Theodore Ts'o
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=20090610202702.GI9002@webber.adilger.int \
--to=adilger@sun.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).