diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2014-01-06 07:49:43 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2014-01-06 07:49:43 -0500 |
commit | 2b47dad866d04f14c328f888ba5406057b8c7d33 (patch) | |
tree | 9eb66c086c2e49080234e0a9a1014624354ebea3 /fs/gfs2/inode.c | |
parent | 534cf9ca553953e4c12fa5f0d23e543f9a6ccbaf (diff) |
GFS2: Remember directory insert point
When we look to see if there is enough space to add a dir
entry without allocation, we have then been repeating the
same search later when we do the actual insertion. This
patch caches the details of the location in the gfs2_diradd
structure, so that we do not have to repeat the search.
This will provide a performance improvement which will be
greater as the size of the directory increases.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r-- | fs/gfs2/inode.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index fa4624feef0f..4acc584038ee 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -516,7 +516,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, | |||
516 | goto fail_quota_locks; | 516 | goto fail_quota_locks; |
517 | } | 517 | } |
518 | 518 | ||
519 | error = gfs2_dir_add(&dip->i_inode, name, ip); | 519 | error = gfs2_dir_add(&dip->i_inode, name, ip, da); |
520 | if (error) | 520 | if (error) |
521 | goto fail_end_trans; | 521 | goto fail_end_trans; |
522 | 522 | ||
@@ -579,7 +579,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, | |||
579 | struct dentry *d; | 579 | struct dentry *d; |
580 | int error; | 580 | int error; |
581 | u32 aflags = 0; | 581 | u32 aflags = 0; |
582 | struct gfs2_diradd da; | 582 | struct gfs2_diradd da = { .bh = NULL, }; |
583 | 583 | ||
584 | if (!name->len || name->len > GFS2_FNAMESIZE) | 584 | if (!name->len || name->len > GFS2_FNAMESIZE) |
585 | return -ENAMETOOLONG; | 585 | return -ENAMETOOLONG; |
@@ -738,6 +738,7 @@ fail_free_inode: | |||
738 | free_inode_nonrcu(inode); | 738 | free_inode_nonrcu(inode); |
739 | inode = NULL; | 739 | inode = NULL; |
740 | fail_gunlock: | 740 | fail_gunlock: |
741 | gfs2_dir_no_add(&da); | ||
741 | gfs2_glock_dq_uninit(ghs); | 742 | gfs2_glock_dq_uninit(ghs); |
742 | if (inode && !IS_ERR(inode)) { | 743 | if (inode && !IS_ERR(inode)) { |
743 | clear_nlink(inode); | 744 | clear_nlink(inode); |
@@ -836,7 +837,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, | |||
836 | struct gfs2_inode *ip = GFS2_I(inode); | 837 | struct gfs2_inode *ip = GFS2_I(inode); |
837 | struct gfs2_holder ghs[2]; | 838 | struct gfs2_holder ghs[2]; |
838 | struct buffer_head *dibh; | 839 | struct buffer_head *dibh; |
839 | struct gfs2_diradd da; | 840 | struct gfs2_diradd da = { .bh = NULL, }; |
840 | int error; | 841 | int error; |
841 | 842 | ||
842 | if (S_ISDIR(inode->i_mode)) | 843 | if (S_ISDIR(inode->i_mode)) |
@@ -918,7 +919,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, | |||
918 | if (error) | 919 | if (error) |
919 | goto out_end_trans; | 920 | goto out_end_trans; |
920 | 921 | ||
921 | error = gfs2_dir_add(dir, &dentry->d_name, ip); | 922 | error = gfs2_dir_add(dir, &dentry->d_name, ip, &da); |
922 | if (error) | 923 | if (error) |
923 | goto out_brelse; | 924 | goto out_brelse; |
924 | 925 | ||
@@ -940,6 +941,7 @@ out_gunlock_q: | |||
940 | if (da.nr_blocks) | 941 | if (da.nr_blocks) |
941 | gfs2_quota_unlock(dip); | 942 | gfs2_quota_unlock(dip); |
942 | out_gunlock: | 943 | out_gunlock: |
944 | gfs2_dir_no_add(&da); | ||
943 | gfs2_glock_dq(ghs + 1); | 945 | gfs2_glock_dq(ghs + 1); |
944 | out_child: | 946 | out_child: |
945 | gfs2_glock_dq(ghs); | 947 | gfs2_glock_dq(ghs); |
@@ -1454,7 +1456,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, | |||
1454 | if (error) | 1456 | if (error) |
1455 | goto out_end_trans; | 1457 | goto out_end_trans; |
1456 | 1458 | ||
1457 | error = gfs2_dir_add(ndir, &ndentry->d_name, ip); | 1459 | error = gfs2_dir_add(ndir, &ndentry->d_name, ip, &da); |
1458 | if (error) | 1460 | if (error) |
1459 | goto out_end_trans; | 1461 | goto out_end_trans; |
1460 | 1462 | ||
@@ -1467,6 +1469,7 @@ out_gunlock_q: | |||
1467 | if (da.nr_blocks) | 1469 | if (da.nr_blocks) |
1468 | gfs2_quota_unlock(ndip); | 1470 | gfs2_quota_unlock(ndip); |
1469 | out_gunlock: | 1471 | out_gunlock: |
1472 | gfs2_dir_no_add(&da); | ||
1470 | while (x--) { | 1473 | while (x--) { |
1471 | gfs2_glock_dq(ghs + x); | 1474 | gfs2_glock_dq(ghs + x); |
1472 | gfs2_holder_uninit(ghs + x); | 1475 | gfs2_holder_uninit(ghs + x); |