aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 01:01:58 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 01:01:58 -0400
commit0650b55497ef583c43d6afc80e11a39e92d9a525 (patch)
tree7605714c36579ac623f4045db2fcb08ca9d298a5 /fs/xfs/xfs_dir2.c
parent2d6dcc6d7e95cc83046b2f97e179e6bbb7921245 (diff)
xfs: introduce directory geometry structure
The directory code has a dependency on the struct xfs_mount to supply the directory block geometry. Block size, block log size, and other parameters are pre-caclulated in the struct xfs_mount or access directly from the superblock embedded in the struct xfs_mount. Extract all of this geometry information out of the struct xfs_mount and superblock and place it into a new struct xfs_da_geometry defined by the directory code. Allocate and initialise it at mount time, and attach it to the struct xfs_mount so it canbe passed back into the directory code appropriately rather than using the struct xfs_mount. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_dir2.c')
-rw-r--r--fs/xfs/xfs_dir2.c73
1 files changed, 60 insertions, 13 deletions
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index e365c98c0f1e..bf0d6dd47242 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -85,11 +85,12 @@ static struct xfs_nameops xfs_ascii_ci_nameops = {
85 .compname = xfs_ascii_ci_compname, 85 .compname = xfs_ascii_ci_compname,
86}; 86};
87 87
88void 88int
89xfs_dir_mount( 89xfs_da_mount(
90 xfs_mount_t *mp) 90 struct xfs_mount *mp)
91{ 91{
92 int nodehdr_size; 92 struct xfs_da_geometry *dageo;
93 int nodehdr_size;
93 94
94 95
95 ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb)); 96 ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
@@ -99,24 +100,64 @@ xfs_dir_mount(
99 mp->m_dir_inode_ops = xfs_dir_get_ops(mp, NULL); 100 mp->m_dir_inode_ops = xfs_dir_get_ops(mp, NULL);
100 mp->m_nondir_inode_ops = xfs_nondir_get_ops(mp, NULL); 101 mp->m_nondir_inode_ops = xfs_nondir_get_ops(mp, NULL);
101 102
102 mp->m_dirblksize = 1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog);
103 mp->m_dirblkfsbs = 1 << mp->m_sb.sb_dirblklog;
104 mp->m_dirdatablk = xfs_dir2_db_to_da(mp, XFS_DIR2_DATA_FIRSTDB(mp));
105 mp->m_dirleafblk = xfs_dir2_db_to_da(mp, XFS_DIR2_LEAF_FIRSTDB(mp));
106 mp->m_dirfreeblk = xfs_dir2_db_to_da(mp, XFS_DIR2_FREE_FIRSTDB(mp));
107
108 nodehdr_size = mp->m_dir_inode_ops->node_hdr_size; 103 nodehdr_size = mp->m_dir_inode_ops->node_hdr_size;
109 mp->m_attr_node_ents = (mp->m_sb.sb_blocksize - nodehdr_size) / 104 mp->m_dir_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
105 KM_SLEEP | KM_MAYFAIL);
106 mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
107 KM_SLEEP | KM_MAYFAIL);
108 if (!mp->m_dir_geo || !mp->m_attr_geo) {
109 kmem_free(mp->m_dir_geo);
110 kmem_free(mp->m_attr_geo);
111 return ENOMEM;
112 }
113
114 /* set up directory geometry */
115 dageo = mp->m_dir_geo;
116 dageo->blklog = mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog;
117 dageo->fsblog = mp->m_sb.sb_blocklog;
118 dageo->blksize = 1 << dageo->blklog;
119 dageo->fsbcount = 1 << mp->m_sb.sb_dirblklog;
120 dageo->datablk = xfs_dir2_byte_to_da(mp, XFS_DIR2_DATA_OFFSET);
121 dageo->leafblk = xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET);
122 dageo->freeblk = xfs_dir2_byte_to_da(mp, XFS_DIR2_FREE_OFFSET);
123 dageo->node_ents = (dageo->blksize - nodehdr_size) /
110 (uint)sizeof(xfs_da_node_entry_t); 124 (uint)sizeof(xfs_da_node_entry_t);
111 mp->m_dir_node_ents = (mp->m_dirblksize - nodehdr_size) / 125 dageo->magicpct = (dageo->blksize * 37) / 100;
126
127 /* set up attribute geometry - single fsb only */
128 dageo = mp->m_attr_geo;
129 dageo->blklog = mp->m_sb.sb_blocklog;
130 dageo->fsblog = mp->m_sb.sb_blocklog;
131 dageo->blksize = 1 << dageo->blklog;
132 dageo->fsbcount = 1;
133 dageo->node_ents = (dageo->blksize - nodehdr_size) /
112 (uint)sizeof(xfs_da_node_entry_t); 134 (uint)sizeof(xfs_da_node_entry_t);
135 dageo->magicpct = (dageo->blksize * 37) / 100;
113 136
114 mp->m_dir_magicpct = (mp->m_dirblksize * 37) / 100;
115 if (xfs_sb_version_hasasciici(&mp->m_sb)) 137 if (xfs_sb_version_hasasciici(&mp->m_sb))
116 mp->m_dirnameops = &xfs_ascii_ci_nameops; 138 mp->m_dirnameops = &xfs_ascii_ci_nameops;
117 else 139 else
118 mp->m_dirnameops = &xfs_default_nameops; 140 mp->m_dirnameops = &xfs_default_nameops;
119 141
142 /* XXX: these are to be removed as code is converted to use geo */
143 mp->m_dirblksize = mp->m_dir_geo->blksize;
144 mp->m_dirblkfsbs = mp->m_dir_geo->fsbcount;
145 mp->m_dirdatablk = mp->m_dir_geo->datablk;
146 mp->m_dirleafblk = mp->m_dir_geo->leafblk;
147 mp->m_dirfreeblk = mp->m_dir_geo->freeblk;
148 mp->m_dir_node_ents = mp->m_dir_geo->node_ents;
149 mp->m_dir_magicpct = mp->m_dir_geo->magicpct;
150 mp->m_attr_node_ents = mp->m_attr_geo->node_ents;
151 mp->m_attr_magicpct = mp->m_attr_geo->magicpct;
152 return 0;
153}
154
155void
156xfs_da_unmount(
157 struct xfs_mount *mp)
158{
159 kmem_free(mp->m_dir_geo);
160 kmem_free(mp->m_attr_geo);
120} 161}
121 162
122/* 163/*
@@ -192,6 +233,7 @@ xfs_dir_init(
192 if (!args) 233 if (!args)
193 return ENOMEM; 234 return ENOMEM;
194 235
236 args->geo = dp->i_mount->m_dir_geo;
195 args->dp = dp; 237 args->dp = dp;
196 args->trans = tp; 238 args->trans = tp;
197 error = xfs_dir2_sf_create(args, pdp->i_ino); 239 error = xfs_dir2_sf_create(args, pdp->i_ino);
@@ -226,6 +268,7 @@ xfs_dir_createname(
226 if (!args) 268 if (!args)
227 return ENOMEM; 269 return ENOMEM;
228 270
271 args->geo = dp->i_mount->m_dir_geo;
229 args->name = name->name; 272 args->name = name->name;
230 args->namelen = name->len; 273 args->namelen = name->len;
231 args->filetype = name->type; 274 args->filetype = name->type;
@@ -320,6 +363,7 @@ xfs_dir_lookup(
320 * annotations into the reclaim path for the ilock. 363 * annotations into the reclaim path for the ilock.
321 */ 364 */
322 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 365 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
366 args->geo = dp->i_mount->m_dir_geo;
323 args->name = name->name; 367 args->name = name->name;
324 args->namelen = name->len; 368 args->namelen = name->len;
325 args->filetype = name->type; 369 args->filetype = name->type;
@@ -391,6 +435,7 @@ xfs_dir_removename(
391 if (!args) 435 if (!args)
392 return ENOMEM; 436 return ENOMEM;
393 437
438 args->geo = dp->i_mount->m_dir_geo;
394 args->name = name->name; 439 args->name = name->name;
395 args->namelen = name->len; 440 args->namelen = name->len;
396 args->filetype = name->type; 441 args->filetype = name->type;
@@ -455,6 +500,7 @@ xfs_dir_replace(
455 if (!args) 500 if (!args)
456 return ENOMEM; 501 return ENOMEM;
457 502
503 args->geo = dp->i_mount->m_dir_geo;
458 args->name = name->name; 504 args->name = name->name;
459 args->namelen = name->len; 505 args->namelen = name->len;
460 args->filetype = name->type; 506 args->filetype = name->type;
@@ -516,6 +562,7 @@ xfs_dir_canenter(
516 if (!args) 562 if (!args)
517 return ENOMEM; 563 return ENOMEM;
518 564
565 args->geo = dp->i_mount->m_dir_geo;
519 args->name = name->name; 566 args->name = name->name;
520 args->namelen = name->len; 567 args->namelen = name->len;
521 args->filetype = name->type; 568 args->filetype = name->type;