2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "xfs_types.h"
23 #include "xfs_trans.h"
27 #include "xfs_mount.h"
28 #include "xfs_da_btree.h"
29 #include "xfs_bmap_btree.h"
30 #include "xfs_dir2_sf.h"
31 #include "xfs_dinode.h"
32 #include "xfs_inode.h"
33 #include "xfs_inode_item.h"
34 #include "xfs_error.h"
35 #include "xfs_dir2_data.h"
36 #include "xfs_dir2_leaf.h"
37 #include "xfs_dir2_block.h"
38 #include "xfs_trace.h"
41 * Prototypes for internal functions.
43 static void xfs_dir2_sf_addname_easy(xfs_da_args_t
*args
,
44 xfs_dir2_sf_entry_t
*sfep
,
45 xfs_dir2_data_aoff_t offset
,
47 static void xfs_dir2_sf_addname_hard(xfs_da_args_t
*args
, int objchange
,
49 static int xfs_dir2_sf_addname_pick(xfs_da_args_t
*args
, int objchange
,
50 xfs_dir2_sf_entry_t
**sfepp
,
51 xfs_dir2_data_aoff_t
*offsetp
);
53 static void xfs_dir2_sf_check(xfs_da_args_t
*args
);
55 #define xfs_dir2_sf_check(args)
58 static void xfs_dir2_sf_toino4(xfs_da_args_t
*args
);
59 static void xfs_dir2_sf_toino8(xfs_da_args_t
*args
);
60 #endif /* XFS_BIG_INUMS */
64 * Inode numbers in short-form directories can come in two versions,
65 * either 4 bytes or 8 bytes wide. These helpers deal with the
66 * two forms transparently by looking at the headers i8count field.
70 struct xfs_dir2_sf
*sfp
,
71 xfs_dir2_inou_t
*from
)
74 return XFS_GET_DIR_INO8(from
->i8
);
76 return XFS_GET_DIR_INO4(from
->i4
);
81 struct xfs_dir2_sf
*sfp
,
86 XFS_PUT_DIR_INO8(ino
, to
->i8
);
88 XFS_PUT_DIR_INO4(ino
, to
->i4
);
92 xfs_dir2_sf_get_parent_ino(
93 struct xfs_dir2_sf
*sfp
)
95 return xfs_dir2_sf_get_ino(sfp
, &sfp
->hdr
.parent
);
99 xfs_dir2_sf_put_parent_ino(
100 struct xfs_dir2_sf
*sfp
,
103 xfs_dir2_sf_put_ino(sfp
, &sfp
->hdr
.parent
, ino
);
107 * In short-form directory entries the inode numbers are stored at variable
108 * offset behind the entry name. The inode numbers may only be accessed
109 * through the helpers below.
111 static xfs_dir2_inou_t
*
113 struct xfs_dir2_sf_entry
*sfep
)
115 return (xfs_dir2_inou_t
*)&sfep
->name
[sfep
->namelen
];
119 xfs_dir2_sfe_get_ino(
120 struct xfs_dir2_sf
*sfp
,
121 struct xfs_dir2_sf_entry
*sfep
)
123 return xfs_dir2_sf_get_ino(sfp
, xfs_dir2_sfe_inop(sfep
));
127 xfs_dir2_sfe_put_ino(
128 struct xfs_dir2_sf
*sfp
,
129 struct xfs_dir2_sf_entry
*sfep
,
132 xfs_dir2_sf_put_ino(sfp
, xfs_dir2_sfe_inop(sfep
), ino
);
136 * Given a block directory (dp/block), calculate its size as a shortform (sf)
137 * directory and a header for the sf directory, if it will fit it the
138 * space currently present in the inode. If it won't fit, the output
139 * size is too big (but not accurate).
141 int /* size for sf form */
142 xfs_dir2_block_sfsize(
143 xfs_inode_t
*dp
, /* incore inode pointer */
144 xfs_dir2_block_t
*block
, /* block directory data */
145 xfs_dir2_sf_hdr_t
*sfhp
) /* output: header for sf form */
147 xfs_dir2_dataptr_t addr
; /* data entry address */
148 xfs_dir2_leaf_entry_t
*blp
; /* leaf area of the block */
149 xfs_dir2_block_tail_t
*btp
; /* tail area of the block */
150 int count
; /* shortform entry count */
151 xfs_dir2_data_entry_t
*dep
; /* data entry in the block */
152 int i
; /* block entry index */
153 int i8count
; /* count of big-inode entries */
154 int isdot
; /* entry is "." */
155 int isdotdot
; /* entry is ".." */
156 xfs_mount_t
*mp
; /* mount structure pointer */
157 int namelen
; /* total name bytes */
158 xfs_ino_t parent
= 0; /* parent inode number */
159 int size
=0; /* total computed size */
163 count
= i8count
= namelen
= 0;
164 btp
= xfs_dir2_block_tail_p(mp
, block
);
165 blp
= xfs_dir2_block_leaf_p(btp
);
168 * Iterate over the block's data entries by using the leaf pointers.
170 for (i
= 0; i
< be32_to_cpu(btp
->count
); i
++) {
171 if ((addr
= be32_to_cpu(blp
[i
].address
)) == XFS_DIR2_NULL_DATAPTR
)
174 * Calculate the pointer to the entry at hand.
176 dep
= (xfs_dir2_data_entry_t
*)
177 ((char *)block
+ xfs_dir2_dataptr_to_off(mp
, addr
));
179 * Detect . and .., so we can special-case them.
180 * . is not included in sf directories.
181 * .. is included by just the parent inode number.
183 isdot
= dep
->namelen
== 1 && dep
->name
[0] == '.';
186 dep
->name
[0] == '.' && dep
->name
[1] == '.';
189 i8count
+= be64_to_cpu(dep
->inumber
) > XFS_DIR2_MAX_SHORT_INUM
;
191 if (!isdot
&& !isdotdot
) {
193 namelen
+= dep
->namelen
;
195 parent
= be64_to_cpu(dep
->inumber
);
197 * Calculate the new size, see if we should give up yet.
199 size
= xfs_dir2_sf_hdr_size(i8count
) + /* header */
200 count
+ /* namelen */
201 count
* (uint
)sizeof(xfs_dir2_sf_off_t
) + /* offset */
203 (i8count
? /* inumber */
204 (uint
)sizeof(xfs_dir2_ino8_t
) * count
:
205 (uint
)sizeof(xfs_dir2_ino4_t
) * count
);
206 if (size
> XFS_IFORK_DSIZE(dp
))
207 return size
; /* size value is a failure */
210 * Create the output header, if it worked.
213 sfhp
->i8count
= i8count
;
214 xfs_dir2_sf_put_parent_ino((xfs_dir2_sf_t
*)sfhp
, parent
);
219 * Convert a block format directory to shortform.
220 * Caller has already checked that it will fit, and built us a header.
223 xfs_dir2_block_to_sf(
224 xfs_da_args_t
*args
, /* operation arguments */
225 xfs_dabuf_t
*bp
, /* block buffer */
226 int size
, /* shortform directory size */
227 xfs_dir2_sf_hdr_t
*sfhp
) /* shortform directory hdr */
229 xfs_dir2_block_t
*block
; /* block structure */
230 xfs_dir2_block_tail_t
*btp
; /* block tail pointer */
231 xfs_dir2_data_entry_t
*dep
; /* data entry pointer */
232 xfs_inode_t
*dp
; /* incore directory inode */
233 xfs_dir2_data_unused_t
*dup
; /* unused data pointer */
234 char *endptr
; /* end of data entries */
235 int error
; /* error return value */
236 int logflags
; /* inode logging flags */
237 xfs_mount_t
*mp
; /* filesystem mount point */
238 char *ptr
; /* current data pointer */
239 xfs_dir2_sf_entry_t
*sfep
; /* shortform entry */
240 xfs_dir2_sf_t
*sfp
; /* shortform structure */
242 trace_xfs_dir2_block_to_sf(args
);
248 * Make a copy of the block data, so we can shrink the inode
249 * and add local data.
251 block
= kmem_alloc(mp
->m_dirblksize
, KM_SLEEP
);
252 memcpy(block
, bp
->data
, mp
->m_dirblksize
);
253 logflags
= XFS_ILOG_CORE
;
254 if ((error
= xfs_dir2_shrink_inode(args
, mp
->m_dirdatablk
, bp
))) {
255 ASSERT(error
!= ENOSPC
);
259 * The buffer is now unconditionally gone, whether
260 * xfs_dir2_shrink_inode worked or not.
262 * Convert the inode to local format.
264 dp
->i_df
.if_flags
&= ~XFS_IFEXTENTS
;
265 dp
->i_df
.if_flags
|= XFS_IFINLINE
;
266 dp
->i_d
.di_format
= XFS_DINODE_FMT_LOCAL
;
267 ASSERT(dp
->i_df
.if_bytes
== 0);
268 xfs_idata_realloc(dp
, size
, XFS_DATA_FORK
);
269 logflags
|= XFS_ILOG_DDATA
;
271 * Copy the header into the newly allocate local space.
273 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
274 memcpy(sfp
, sfhp
, xfs_dir2_sf_hdr_size(sfhp
->i8count
));
275 dp
->i_d
.di_size
= size
;
277 * Set up to loop over the block's entries.
279 btp
= xfs_dir2_block_tail_p(mp
, block
);
280 ptr
= (char *)block
->u
;
281 endptr
= (char *)xfs_dir2_block_leaf_p(btp
);
282 sfep
= xfs_dir2_sf_firstentry(sfp
);
284 * Loop over the active and unused entries.
285 * Stop when we reach the leaf/tail portion of the block.
287 while (ptr
< endptr
) {
289 * If it's unused, just skip over it.
291 dup
= (xfs_dir2_data_unused_t
*)ptr
;
292 if (be16_to_cpu(dup
->freetag
) == XFS_DIR2_DATA_FREE_TAG
) {
293 ptr
+= be16_to_cpu(dup
->length
);
296 dep
= (xfs_dir2_data_entry_t
*)ptr
;
300 if (dep
->namelen
== 1 && dep
->name
[0] == '.')
301 ASSERT(be64_to_cpu(dep
->inumber
) == dp
->i_ino
);
303 * Skip .., but make sure the inode number is right.
305 else if (dep
->namelen
== 2 &&
306 dep
->name
[0] == '.' && dep
->name
[1] == '.')
307 ASSERT(be64_to_cpu(dep
->inumber
) ==
308 xfs_dir2_sf_get_parent_ino(sfp
));
310 * Normal entry, copy it into shortform.
313 sfep
->namelen
= dep
->namelen
;
314 xfs_dir2_sf_put_offset(sfep
,
315 (xfs_dir2_data_aoff_t
)
316 ((char *)dep
- (char *)block
));
317 memcpy(sfep
->name
, dep
->name
, dep
->namelen
);
318 xfs_dir2_sfe_put_ino(sfp
, sfep
,
319 be64_to_cpu(dep
->inumber
));
321 sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
);
323 ptr
+= xfs_dir2_data_entsize(dep
->namelen
);
325 ASSERT((char *)sfep
- (char *)sfp
== size
);
326 xfs_dir2_sf_check(args
);
328 xfs_trans_log_inode(args
->trans
, dp
, logflags
);
334 * Add a name to a shortform directory.
335 * There are two algorithms, "easy" and "hard" which we decide on
336 * before changing anything.
337 * Convert to block form if necessary, if the new entry won't fit.
341 xfs_da_args_t
*args
) /* operation arguments */
343 int add_entsize
; /* size of the new entry */
344 xfs_inode_t
*dp
; /* incore directory inode */
345 int error
; /* error return value */
346 int incr_isize
; /* total change in size */
347 int new_isize
; /* di_size after adding name */
348 int objchange
; /* changing to 8-byte inodes */
349 xfs_dir2_data_aoff_t offset
= 0; /* offset for new entry */
350 int old_isize
; /* di_size before adding name */
351 int pick
; /* which algorithm to use */
352 xfs_dir2_sf_t
*sfp
; /* shortform structure */
353 xfs_dir2_sf_entry_t
*sfep
= NULL
; /* shortform entry */
355 trace_xfs_dir2_sf_addname(args
);
357 ASSERT(xfs_dir2_sf_lookup(args
) == ENOENT
);
359 ASSERT(dp
->i_df
.if_flags
& XFS_IFINLINE
);
361 * Make sure the shortform value has some of its header.
363 if (dp
->i_d
.di_size
< offsetof(xfs_dir2_sf_hdr_t
, parent
)) {
364 ASSERT(XFS_FORCED_SHUTDOWN(dp
->i_mount
));
365 return XFS_ERROR(EIO
);
367 ASSERT(dp
->i_df
.if_bytes
== dp
->i_d
.di_size
);
368 ASSERT(dp
->i_df
.if_u1
.if_data
!= NULL
);
369 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
370 ASSERT(dp
->i_d
.di_size
>= xfs_dir2_sf_hdr_size(sfp
->hdr
.i8count
));
372 * Compute entry (and change in) size.
374 add_entsize
= xfs_dir2_sf_entsize_byname(sfp
, args
->namelen
);
375 incr_isize
= add_entsize
;
379 * Do we have to change to 8 byte inodes?
381 if (args
->inumber
> XFS_DIR2_MAX_SHORT_INUM
&& sfp
->hdr
.i8count
== 0) {
383 * Yes, adjust the entry size and the total size.
386 (uint
)sizeof(xfs_dir2_ino8_t
) -
387 (uint
)sizeof(xfs_dir2_ino4_t
);
389 (sfp
->hdr
.count
+ 2) *
390 ((uint
)sizeof(xfs_dir2_ino8_t
) -
391 (uint
)sizeof(xfs_dir2_ino4_t
));
395 old_isize
= (int)dp
->i_d
.di_size
;
396 new_isize
= old_isize
+ incr_isize
;
398 * Won't fit as shortform any more (due to size),
399 * or the pick routine says it won't (due to offset values).
401 if (new_isize
> XFS_IFORK_DSIZE(dp
) ||
403 xfs_dir2_sf_addname_pick(args
, objchange
, &sfep
, &offset
)) == 0) {
405 * Just checking or no space reservation, it doesn't fit.
407 if ((args
->op_flags
& XFS_DA_OP_JUSTCHECK
) || args
->total
== 0)
408 return XFS_ERROR(ENOSPC
);
410 * Convert to block form then add the name.
412 error
= xfs_dir2_sf_to_block(args
);
415 return xfs_dir2_block_addname(args
);
418 * Just checking, it fits.
420 if (args
->op_flags
& XFS_DA_OP_JUSTCHECK
)
423 * Do it the easy way - just add it at the end.
426 xfs_dir2_sf_addname_easy(args
, sfep
, offset
, new_isize
);
428 * Do it the hard way - look for a place to insert the new entry.
429 * Convert to 8 byte inode numbers first if necessary.
435 xfs_dir2_sf_toino8(args
);
437 xfs_dir2_sf_addname_hard(args
, objchange
, new_isize
);
439 xfs_trans_log_inode(args
->trans
, dp
, XFS_ILOG_CORE
| XFS_ILOG_DDATA
);
444 * Add the new entry the "easy" way.
445 * This is copying the old directory and adding the new entry at the end.
446 * Since it's sorted by "offset" we need room after the last offset
447 * that's already there, and then room to convert to a block directory.
448 * This is already checked by the pick routine.
451 xfs_dir2_sf_addname_easy(
452 xfs_da_args_t
*args
, /* operation arguments */
453 xfs_dir2_sf_entry_t
*sfep
, /* pointer to new entry */
454 xfs_dir2_data_aoff_t offset
, /* offset to use for new ent */
455 int new_isize
) /* new directory size */
457 int byteoff
; /* byte offset in sf dir */
458 xfs_inode_t
*dp
; /* incore directory inode */
459 xfs_dir2_sf_t
*sfp
; /* shortform structure */
463 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
464 byteoff
= (int)((char *)sfep
- (char *)sfp
);
466 * Grow the in-inode space.
468 xfs_idata_realloc(dp
, xfs_dir2_sf_entsize_byname(sfp
, args
->namelen
),
471 * Need to set up again due to realloc of the inode data.
473 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
474 sfep
= (xfs_dir2_sf_entry_t
*)((char *)sfp
+ byteoff
);
476 * Fill in the new entry.
478 sfep
->namelen
= args
->namelen
;
479 xfs_dir2_sf_put_offset(sfep
, offset
);
480 memcpy(sfep
->name
, args
->name
, sfep
->namelen
);
481 xfs_dir2_sfe_put_ino(sfp
, sfep
, args
->inumber
);
483 * Update the header and inode.
487 if (args
->inumber
> XFS_DIR2_MAX_SHORT_INUM
)
490 dp
->i_d
.di_size
= new_isize
;
491 xfs_dir2_sf_check(args
);
495 * Add the new entry the "hard" way.
496 * The caller has already converted to 8 byte inode numbers if necessary,
497 * in which case we need to leave the i8count at 1.
498 * Find a hole that the new entry will fit into, and copy
499 * the first part of the entries, the new entry, and the last part of
504 xfs_dir2_sf_addname_hard(
505 xfs_da_args_t
*args
, /* operation arguments */
506 int objchange
, /* changing inode number size */
507 int new_isize
) /* new directory size */
509 int add_datasize
; /* data size need for new ent */
510 char *buf
; /* buffer for old */
511 xfs_inode_t
*dp
; /* incore directory inode */
512 int eof
; /* reached end of old dir */
513 int nbytes
; /* temp for byte copies */
514 xfs_dir2_data_aoff_t new_offset
; /* next offset value */
515 xfs_dir2_data_aoff_t offset
; /* current offset value */
516 int old_isize
; /* previous di_size */
517 xfs_dir2_sf_entry_t
*oldsfep
; /* entry in original dir */
518 xfs_dir2_sf_t
*oldsfp
; /* original shortform dir */
519 xfs_dir2_sf_entry_t
*sfep
; /* entry in new dir */
520 xfs_dir2_sf_t
*sfp
; /* new shortform dir */
523 * Copy the old directory to the stack buffer.
527 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
528 old_isize
= (int)dp
->i_d
.di_size
;
529 buf
= kmem_alloc(old_isize
, KM_SLEEP
);
530 oldsfp
= (xfs_dir2_sf_t
*)buf
;
531 memcpy(oldsfp
, sfp
, old_isize
);
533 * Loop over the old directory finding the place we're going
534 * to insert the new entry.
535 * If it's going to end up at the end then oldsfep will point there.
537 for (offset
= XFS_DIR2_DATA_FIRST_OFFSET
,
538 oldsfep
= xfs_dir2_sf_firstentry(oldsfp
),
539 add_datasize
= xfs_dir2_data_entsize(args
->namelen
),
540 eof
= (char *)oldsfep
== &buf
[old_isize
];
542 offset
= new_offset
+ xfs_dir2_data_entsize(oldsfep
->namelen
),
543 oldsfep
= xfs_dir2_sf_nextentry(oldsfp
, oldsfep
),
544 eof
= (char *)oldsfep
== &buf
[old_isize
]) {
545 new_offset
= xfs_dir2_sf_get_offset(oldsfep
);
546 if (offset
+ add_datasize
<= new_offset
)
550 * Get rid of the old directory, then allocate space for
551 * the new one. We do this so xfs_idata_realloc won't copy
554 xfs_idata_realloc(dp
, -old_isize
, XFS_DATA_FORK
);
555 xfs_idata_realloc(dp
, new_isize
, XFS_DATA_FORK
);
557 * Reset the pointer since the buffer was reallocated.
559 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
561 * Copy the first part of the directory, including the header.
563 nbytes
= (int)((char *)oldsfep
- (char *)oldsfp
);
564 memcpy(sfp
, oldsfp
, nbytes
);
565 sfep
= (xfs_dir2_sf_entry_t
*)((char *)sfp
+ nbytes
);
567 * Fill in the new entry, and update the header counts.
569 sfep
->namelen
= args
->namelen
;
570 xfs_dir2_sf_put_offset(sfep
, offset
);
571 memcpy(sfep
->name
, args
->name
, sfep
->namelen
);
572 xfs_dir2_sfe_put_ino(sfp
, sfep
, args
->inumber
);
575 if (args
->inumber
> XFS_DIR2_MAX_SHORT_INUM
&& !objchange
)
579 * If there's more left to copy, do that.
582 sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
);
583 memcpy(sfep
, oldsfep
, old_isize
- nbytes
);
586 dp
->i_d
.di_size
= new_isize
;
587 xfs_dir2_sf_check(args
);
591 * Decide if the new entry will fit at all.
592 * If it will fit, pick between adding the new entry to the end (easy)
593 * or somewhere else (hard).
594 * Return 0 (won't fit), 1 (easy), 2 (hard).
597 static int /* pick result */
598 xfs_dir2_sf_addname_pick(
599 xfs_da_args_t
*args
, /* operation arguments */
600 int objchange
, /* inode # size changes */
601 xfs_dir2_sf_entry_t
**sfepp
, /* out(1): new entry ptr */
602 xfs_dir2_data_aoff_t
*offsetp
) /* out(1): new offset */
604 xfs_inode_t
*dp
; /* incore directory inode */
605 int holefit
; /* found hole it will fit in */
606 int i
; /* entry number */
607 xfs_mount_t
*mp
; /* filesystem mount point */
608 xfs_dir2_data_aoff_t offset
; /* data block offset */
609 xfs_dir2_sf_entry_t
*sfep
; /* shortform entry */
610 xfs_dir2_sf_t
*sfp
; /* shortform structure */
611 int size
; /* entry's data size */
612 int used
; /* data bytes used */
617 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
618 size
= xfs_dir2_data_entsize(args
->namelen
);
619 offset
= XFS_DIR2_DATA_FIRST_OFFSET
;
620 sfep
= xfs_dir2_sf_firstentry(sfp
);
623 * Loop over sf entries.
624 * Keep track of data offset and whether we've seen a place
625 * to insert the new entry.
627 for (i
= 0; i
< sfp
->hdr
.count
; i
++) {
629 holefit
= offset
+ size
<= xfs_dir2_sf_get_offset(sfep
);
630 offset
= xfs_dir2_sf_get_offset(sfep
) +
631 xfs_dir2_data_entsize(sfep
->namelen
);
632 sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
);
635 * Calculate data bytes used excluding the new entry, if this
636 * was a data block (block form directory).
639 (sfp
->hdr
.count
+ 3) * (uint
)sizeof(xfs_dir2_leaf_entry_t
) +
640 (uint
)sizeof(xfs_dir2_block_tail_t
);
642 * If it won't fit in a block form then we can't insert it,
643 * we'll go back, convert to block, then try the insert and convert
646 if (used
+ (holefit
? 0 : size
) > mp
->m_dirblksize
)
649 * If changing the inode number size, do it the hard way.
656 ASSERT(objchange
== 0);
659 * If it won't fit at the end then do it the hard way (use the hole).
661 if (used
+ size
> mp
->m_dirblksize
)
664 * Do it the easy way.
673 * Check consistency of shortform directory, assert if bad.
677 xfs_da_args_t
*args
) /* operation arguments */
679 xfs_inode_t
*dp
; /* incore directory inode */
680 int i
; /* entry number */
681 int i8count
; /* number of big inode#s */
682 xfs_ino_t ino
; /* entry inode number */
683 int offset
; /* data offset */
684 xfs_dir2_sf_entry_t
*sfep
; /* shortform dir entry */
685 xfs_dir2_sf_t
*sfp
; /* shortform structure */
689 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
690 offset
= XFS_DIR2_DATA_FIRST_OFFSET
;
691 ino
= xfs_dir2_sf_get_parent_ino(sfp
);
692 i8count
= ino
> XFS_DIR2_MAX_SHORT_INUM
;
694 for (i
= 0, sfep
= xfs_dir2_sf_firstentry(sfp
);
696 i
++, sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
)) {
697 ASSERT(xfs_dir2_sf_get_offset(sfep
) >= offset
);
698 ino
= xfs_dir2_sfe_get_ino(sfp
, sfep
);
699 i8count
+= ino
> XFS_DIR2_MAX_SHORT_INUM
;
701 xfs_dir2_sf_get_offset(sfep
) +
702 xfs_dir2_data_entsize(sfep
->namelen
);
704 ASSERT(i8count
== sfp
->hdr
.i8count
);
705 ASSERT(XFS_BIG_INUMS
|| i8count
== 0);
706 ASSERT((char *)sfep
- (char *)sfp
== dp
->i_d
.di_size
);
708 (sfp
->hdr
.count
+ 2) * (uint
)sizeof(xfs_dir2_leaf_entry_t
) +
709 (uint
)sizeof(xfs_dir2_block_tail_t
) <=
710 dp
->i_mount
->m_dirblksize
);
715 * Create a new (shortform) directory.
717 int /* error, always 0 */
719 xfs_da_args_t
*args
, /* operation arguments */
720 xfs_ino_t pino
) /* parent inode number */
722 xfs_inode_t
*dp
; /* incore directory inode */
723 int i8count
; /* parent inode is an 8-byte number */
724 xfs_dir2_sf_t
*sfp
; /* shortform structure */
725 int size
; /* directory size */
727 trace_xfs_dir2_sf_create(args
);
732 ASSERT(dp
->i_d
.di_size
== 0);
734 * If it's currently a zero-length extent file,
735 * convert it to local format.
737 if (dp
->i_d
.di_format
== XFS_DINODE_FMT_EXTENTS
) {
738 dp
->i_df
.if_flags
&= ~XFS_IFEXTENTS
; /* just in case */
739 dp
->i_d
.di_format
= XFS_DINODE_FMT_LOCAL
;
740 xfs_trans_log_inode(args
->trans
, dp
, XFS_ILOG_CORE
);
741 dp
->i_df
.if_flags
|= XFS_IFINLINE
;
743 ASSERT(dp
->i_df
.if_flags
& XFS_IFINLINE
);
744 ASSERT(dp
->i_df
.if_bytes
== 0);
745 i8count
= pino
> XFS_DIR2_MAX_SHORT_INUM
;
746 size
= xfs_dir2_sf_hdr_size(i8count
);
748 * Make a buffer for the data.
750 xfs_idata_realloc(dp
, size
, XFS_DATA_FORK
);
752 * Fill in the header,
754 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
755 sfp
->hdr
.i8count
= i8count
;
757 * Now can put in the inode number, since i8count is set.
759 xfs_dir2_sf_put_parent_ino(sfp
, pino
);
761 dp
->i_d
.di_size
= size
;
762 xfs_dir2_sf_check(args
);
763 xfs_trans_log_inode(args
->trans
, dp
, XFS_ILOG_CORE
| XFS_ILOG_DDATA
);
768 xfs_dir2_sf_getdents(
769 xfs_inode_t
*dp
, /* incore directory inode */
774 int i
; /* shortform entry number */
775 xfs_mount_t
*mp
; /* filesystem mount point */
776 xfs_dir2_dataptr_t off
; /* current entry's offset */
777 xfs_dir2_sf_entry_t
*sfep
; /* shortform directory entry */
778 xfs_dir2_sf_t
*sfp
; /* shortform structure */
779 xfs_dir2_dataptr_t dot_offset
;
780 xfs_dir2_dataptr_t dotdot_offset
;
785 ASSERT(dp
->i_df
.if_flags
& XFS_IFINLINE
);
787 * Give up if the directory is way too short.
789 if (dp
->i_d
.di_size
< offsetof(xfs_dir2_sf_hdr_t
, parent
)) {
790 ASSERT(XFS_FORCED_SHUTDOWN(mp
));
791 return XFS_ERROR(EIO
);
794 ASSERT(dp
->i_df
.if_bytes
== dp
->i_d
.di_size
);
795 ASSERT(dp
->i_df
.if_u1
.if_data
!= NULL
);
797 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
799 ASSERT(dp
->i_d
.di_size
>= xfs_dir2_sf_hdr_size(sfp
->hdr
.i8count
));
802 * If the block number in the offset is out of range, we're done.
804 if (xfs_dir2_dataptr_to_db(mp
, *offset
) > mp
->m_dirdatablk
)
808 * Precalculate offsets for . and .. as we will always need them.
810 * XXX(hch): the second argument is sometimes 0 and sometimes
813 dot_offset
= xfs_dir2_db_off_to_dataptr(mp
, mp
->m_dirdatablk
,
814 XFS_DIR2_DATA_DOT_OFFSET
);
815 dotdot_offset
= xfs_dir2_db_off_to_dataptr(mp
, mp
->m_dirdatablk
,
816 XFS_DIR2_DATA_DOTDOT_OFFSET
);
819 * Put . entry unless we're starting past it.
821 if (*offset
<= dot_offset
) {
822 if (filldir(dirent
, ".", 1, dot_offset
& 0x7fffffff, dp
->i_ino
, DT_DIR
)) {
823 *offset
= dot_offset
& 0x7fffffff;
829 * Put .. entry unless we're starting past it.
831 if (*offset
<= dotdot_offset
) {
832 ino
= xfs_dir2_sf_get_parent_ino(sfp
);
833 if (filldir(dirent
, "..", 2, dotdot_offset
& 0x7fffffff, ino
, DT_DIR
)) {
834 *offset
= dotdot_offset
& 0x7fffffff;
840 * Loop while there are more entries and put'ing works.
842 sfep
= xfs_dir2_sf_firstentry(sfp
);
843 for (i
= 0; i
< sfp
->hdr
.count
; i
++) {
844 off
= xfs_dir2_db_off_to_dataptr(mp
, mp
->m_dirdatablk
,
845 xfs_dir2_sf_get_offset(sfep
));
848 sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
);
852 ino
= xfs_dir2_sfe_get_ino(sfp
, sfep
);
853 if (filldir(dirent
, (char *)sfep
->name
, sfep
->namelen
,
854 off
& 0x7fffffff, ino
, DT_UNKNOWN
)) {
855 *offset
= off
& 0x7fffffff;
858 sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
);
861 *offset
= xfs_dir2_db_off_to_dataptr(mp
, mp
->m_dirdatablk
+ 1, 0) &
867 * Lookup an entry in a shortform directory.
868 * Returns EEXIST if found, ENOENT if not found.
872 xfs_da_args_t
*args
) /* operation arguments */
874 xfs_inode_t
*dp
; /* incore directory inode */
875 int i
; /* entry index */
877 xfs_dir2_sf_entry_t
*sfep
; /* shortform directory entry */
878 xfs_dir2_sf_t
*sfp
; /* shortform structure */
879 enum xfs_dacmp cmp
; /* comparison result */
880 xfs_dir2_sf_entry_t
*ci_sfep
; /* case-insens. entry */
882 trace_xfs_dir2_sf_lookup(args
);
884 xfs_dir2_sf_check(args
);
887 ASSERT(dp
->i_df
.if_flags
& XFS_IFINLINE
);
889 * Bail out if the directory is way too short.
891 if (dp
->i_d
.di_size
< offsetof(xfs_dir2_sf_hdr_t
, parent
)) {
892 ASSERT(XFS_FORCED_SHUTDOWN(dp
->i_mount
));
893 return XFS_ERROR(EIO
);
895 ASSERT(dp
->i_df
.if_bytes
== dp
->i_d
.di_size
);
896 ASSERT(dp
->i_df
.if_u1
.if_data
!= NULL
);
897 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
898 ASSERT(dp
->i_d
.di_size
>= xfs_dir2_sf_hdr_size(sfp
->hdr
.i8count
));
902 if (args
->namelen
== 1 && args
->name
[0] == '.') {
903 args
->inumber
= dp
->i_ino
;
904 args
->cmpresult
= XFS_CMP_EXACT
;
905 return XFS_ERROR(EEXIST
);
908 * Special case for ..
910 if (args
->namelen
== 2 &&
911 args
->name
[0] == '.' && args
->name
[1] == '.') {
912 args
->inumber
= xfs_dir2_sf_get_parent_ino(sfp
);
913 args
->cmpresult
= XFS_CMP_EXACT
;
914 return XFS_ERROR(EEXIST
);
917 * Loop over all the entries trying to match ours.
920 for (i
= 0, sfep
= xfs_dir2_sf_firstentry(sfp
); i
< sfp
->hdr
.count
;
921 i
++, sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
)) {
923 * Compare name and if it's an exact match, return the inode
924 * number. If it's the first case-insensitive match, store the
925 * inode number and continue looking for an exact match.
927 cmp
= dp
->i_mount
->m_dirnameops
->compname(args
, sfep
->name
,
929 if (cmp
!= XFS_CMP_DIFFERENT
&& cmp
!= args
->cmpresult
) {
930 args
->cmpresult
= cmp
;
931 args
->inumber
= xfs_dir2_sfe_get_ino(sfp
, sfep
);
932 if (cmp
== XFS_CMP_EXACT
)
933 return XFS_ERROR(EEXIST
);
937 ASSERT(args
->op_flags
& XFS_DA_OP_OKNOENT
);
939 * Here, we can only be doing a lookup (not a rename or replace).
940 * If a case-insensitive match was not found, return ENOENT.
943 return XFS_ERROR(ENOENT
);
944 /* otherwise process the CI match as required by the caller */
945 error
= xfs_dir_cilookup_result(args
, ci_sfep
->name
, ci_sfep
->namelen
);
946 return XFS_ERROR(error
);
950 * Remove an entry from a shortform directory.
953 xfs_dir2_sf_removename(
956 int byteoff
; /* offset of removed entry */
957 xfs_inode_t
*dp
; /* incore directory inode */
958 int entsize
; /* this entry's size */
959 int i
; /* shortform entry index */
960 int newsize
; /* new inode size */
961 int oldsize
; /* old inode size */
962 xfs_dir2_sf_entry_t
*sfep
; /* shortform directory entry */
963 xfs_dir2_sf_t
*sfp
; /* shortform structure */
965 trace_xfs_dir2_sf_removename(args
);
969 ASSERT(dp
->i_df
.if_flags
& XFS_IFINLINE
);
970 oldsize
= (int)dp
->i_d
.di_size
;
972 * Bail out if the directory is way too short.
974 if (oldsize
< offsetof(xfs_dir2_sf_hdr_t
, parent
)) {
975 ASSERT(XFS_FORCED_SHUTDOWN(dp
->i_mount
));
976 return XFS_ERROR(EIO
);
978 ASSERT(dp
->i_df
.if_bytes
== oldsize
);
979 ASSERT(dp
->i_df
.if_u1
.if_data
!= NULL
);
980 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
981 ASSERT(oldsize
>= xfs_dir2_sf_hdr_size(sfp
->hdr
.i8count
));
983 * Loop over the old directory entries.
984 * Find the one we're deleting.
986 for (i
= 0, sfep
= xfs_dir2_sf_firstentry(sfp
); i
< sfp
->hdr
.count
;
987 i
++, sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
)) {
988 if (xfs_da_compname(args
, sfep
->name
, sfep
->namelen
) ==
990 ASSERT(xfs_dir2_sfe_get_ino(sfp
, sfep
) ==
998 if (i
== sfp
->hdr
.count
)
999 return XFS_ERROR(ENOENT
);
1003 byteoff
= (int)((char *)sfep
- (char *)sfp
);
1004 entsize
= xfs_dir2_sf_entsize_byname(sfp
, args
->namelen
);
1005 newsize
= oldsize
- entsize
;
1007 * Copy the part if any after the removed entry, sliding it down.
1009 if (byteoff
+ entsize
< oldsize
)
1010 memmove((char *)sfp
+ byteoff
, (char *)sfp
+ byteoff
+ entsize
,
1011 oldsize
- (byteoff
+ entsize
));
1013 * Fix up the header and file size.
1016 dp
->i_d
.di_size
= newsize
;
1018 * Reallocate, making it smaller.
1020 xfs_idata_realloc(dp
, newsize
- oldsize
, XFS_DATA_FORK
);
1021 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
1024 * Are we changing inode number size?
1026 if (args
->inumber
> XFS_DIR2_MAX_SHORT_INUM
) {
1027 if (sfp
->hdr
.i8count
== 1)
1028 xfs_dir2_sf_toino4(args
);
1033 xfs_dir2_sf_check(args
);
1034 xfs_trans_log_inode(args
->trans
, dp
, XFS_ILOG_CORE
| XFS_ILOG_DDATA
);
1039 * Replace the inode number of an entry in a shortform directory.
1042 xfs_dir2_sf_replace(
1043 xfs_da_args_t
*args
) /* operation arguments */
1045 xfs_inode_t
*dp
; /* incore directory inode */
1046 int i
; /* entry index */
1047 #if XFS_BIG_INUMS || defined(DEBUG)
1048 xfs_ino_t ino
=0; /* entry old inode number */
1051 int i8elevated
; /* sf_toino8 set i8count=1 */
1053 xfs_dir2_sf_entry_t
*sfep
; /* shortform directory entry */
1054 xfs_dir2_sf_t
*sfp
; /* shortform structure */
1056 trace_xfs_dir2_sf_replace(args
);
1060 ASSERT(dp
->i_df
.if_flags
& XFS_IFINLINE
);
1062 * Bail out if the shortform directory is way too small.
1064 if (dp
->i_d
.di_size
< offsetof(xfs_dir2_sf_hdr_t
, parent
)) {
1065 ASSERT(XFS_FORCED_SHUTDOWN(dp
->i_mount
));
1066 return XFS_ERROR(EIO
);
1068 ASSERT(dp
->i_df
.if_bytes
== dp
->i_d
.di_size
);
1069 ASSERT(dp
->i_df
.if_u1
.if_data
!= NULL
);
1070 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
1071 ASSERT(dp
->i_d
.di_size
>= xfs_dir2_sf_hdr_size(sfp
->hdr
.i8count
));
1074 * New inode number is large, and need to convert to 8-byte inodes.
1076 if (args
->inumber
> XFS_DIR2_MAX_SHORT_INUM
&& sfp
->hdr
.i8count
== 0) {
1077 int error
; /* error return value */
1078 int newsize
; /* new inode size */
1082 (sfp
->hdr
.count
+ 1) *
1083 ((uint
)sizeof(xfs_dir2_ino8_t
) -
1084 (uint
)sizeof(xfs_dir2_ino4_t
));
1086 * Won't fit as shortform, convert to block then do replace.
1088 if (newsize
> XFS_IFORK_DSIZE(dp
)) {
1089 error
= xfs_dir2_sf_to_block(args
);
1093 return xfs_dir2_block_replace(args
);
1096 * Still fits, convert to 8-byte now.
1098 xfs_dir2_sf_toino8(args
);
1100 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
1104 ASSERT(args
->namelen
!= 1 || args
->name
[0] != '.');
1106 * Replace ..'s entry.
1108 if (args
->namelen
== 2 &&
1109 args
->name
[0] == '.' && args
->name
[1] == '.') {
1110 #if XFS_BIG_INUMS || defined(DEBUG)
1111 ino
= xfs_dir2_sf_get_parent_ino(sfp
);
1112 ASSERT(args
->inumber
!= ino
);
1114 xfs_dir2_sf_put_parent_ino(sfp
, args
->inumber
);
1117 * Normal entry, look for the name.
1120 for (i
= 0, sfep
= xfs_dir2_sf_firstentry(sfp
);
1122 i
++, sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
)) {
1123 if (xfs_da_compname(args
, sfep
->name
, sfep
->namelen
) ==
1125 #if XFS_BIG_INUMS || defined(DEBUG)
1126 ino
= xfs_dir2_sfe_get_ino(sfp
, sfep
);
1127 ASSERT(args
->inumber
!= ino
);
1129 xfs_dir2_sfe_put_ino(sfp
, sfep
, args
->inumber
);
1136 if (i
== sfp
->hdr
.count
) {
1137 ASSERT(args
->op_flags
& XFS_DA_OP_OKNOENT
);
1140 xfs_dir2_sf_toino4(args
);
1142 return XFS_ERROR(ENOENT
);
1147 * See if the old number was large, the new number is small.
1149 if (ino
> XFS_DIR2_MAX_SHORT_INUM
&&
1150 args
->inumber
<= XFS_DIR2_MAX_SHORT_INUM
) {
1152 * And the old count was one, so need to convert to small.
1154 if (sfp
->hdr
.i8count
== 1)
1155 xfs_dir2_sf_toino4(args
);
1160 * See if the old number was small, the new number is large.
1162 if (ino
<= XFS_DIR2_MAX_SHORT_INUM
&&
1163 args
->inumber
> XFS_DIR2_MAX_SHORT_INUM
) {
1165 * add to the i8count unless we just converted to 8-byte
1166 * inodes (which does an implied i8count = 1)
1168 ASSERT(sfp
->hdr
.i8count
!= 0);
1173 xfs_dir2_sf_check(args
);
1174 xfs_trans_log_inode(args
->trans
, dp
, XFS_ILOG_DDATA
);
1180 * Convert from 8-byte inode numbers to 4-byte inode numbers.
1181 * The last 8-byte inode number is gone, but the count is still 1.
1185 xfs_da_args_t
*args
) /* operation arguments */
1187 char *buf
; /* old dir's buffer */
1188 xfs_inode_t
*dp
; /* incore directory inode */
1189 int i
; /* entry index */
1190 int newsize
; /* new inode size */
1191 xfs_dir2_sf_entry_t
*oldsfep
; /* old sf entry */
1192 xfs_dir2_sf_t
*oldsfp
; /* old sf directory */
1193 int oldsize
; /* old inode size */
1194 xfs_dir2_sf_entry_t
*sfep
; /* new sf entry */
1195 xfs_dir2_sf_t
*sfp
; /* new sf directory */
1197 trace_xfs_dir2_sf_toino4(args
);
1202 * Copy the old directory to the buffer.
1203 * Then nuke it from the inode, and add the new buffer to the inode.
1204 * Don't want xfs_idata_realloc copying the data here.
1206 oldsize
= dp
->i_df
.if_bytes
;
1207 buf
= kmem_alloc(oldsize
, KM_SLEEP
);
1208 oldsfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
1209 ASSERT(oldsfp
->hdr
.i8count
== 1);
1210 memcpy(buf
, oldsfp
, oldsize
);
1212 * Compute the new inode size.
1216 (oldsfp
->hdr
.count
+ 1) *
1217 ((uint
)sizeof(xfs_dir2_ino8_t
) - (uint
)sizeof(xfs_dir2_ino4_t
));
1218 xfs_idata_realloc(dp
, -oldsize
, XFS_DATA_FORK
);
1219 xfs_idata_realloc(dp
, newsize
, XFS_DATA_FORK
);
1221 * Reset our pointers, the data has moved.
1223 oldsfp
= (xfs_dir2_sf_t
*)buf
;
1224 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
1226 * Fill in the new header.
1228 sfp
->hdr
.count
= oldsfp
->hdr
.count
;
1229 sfp
->hdr
.i8count
= 0;
1230 xfs_dir2_sf_put_parent_ino(sfp
, xfs_dir2_sf_get_parent_ino(oldsfp
));
1232 * Copy the entries field by field.
1234 for (i
= 0, sfep
= xfs_dir2_sf_firstentry(sfp
),
1235 oldsfep
= xfs_dir2_sf_firstentry(oldsfp
);
1237 i
++, sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
),
1238 oldsfep
= xfs_dir2_sf_nextentry(oldsfp
, oldsfep
)) {
1239 sfep
->namelen
= oldsfep
->namelen
;
1240 sfep
->offset
= oldsfep
->offset
;
1241 memcpy(sfep
->name
, oldsfep
->name
, sfep
->namelen
);
1242 xfs_dir2_sfe_put_ino(sfp
, sfep
,
1243 xfs_dir2_sfe_get_ino(oldsfp
, oldsfep
));
1246 * Clean up the inode.
1249 dp
->i_d
.di_size
= newsize
;
1250 xfs_trans_log_inode(args
->trans
, dp
, XFS_ILOG_CORE
| XFS_ILOG_DDATA
);
1254 * Convert from 4-byte inode numbers to 8-byte inode numbers.
1255 * The new 8-byte inode number is not there yet, we leave with the
1256 * count 1 but no corresponding entry.
1260 xfs_da_args_t
*args
) /* operation arguments */
1262 char *buf
; /* old dir's buffer */
1263 xfs_inode_t
*dp
; /* incore directory inode */
1264 int i
; /* entry index */
1265 int newsize
; /* new inode size */
1266 xfs_dir2_sf_entry_t
*oldsfep
; /* old sf entry */
1267 xfs_dir2_sf_t
*oldsfp
; /* old sf directory */
1268 int oldsize
; /* old inode size */
1269 xfs_dir2_sf_entry_t
*sfep
; /* new sf entry */
1270 xfs_dir2_sf_t
*sfp
; /* new sf directory */
1272 trace_xfs_dir2_sf_toino8(args
);
1277 * Copy the old directory to the buffer.
1278 * Then nuke it from the inode, and add the new buffer to the inode.
1279 * Don't want xfs_idata_realloc copying the data here.
1281 oldsize
= dp
->i_df
.if_bytes
;
1282 buf
= kmem_alloc(oldsize
, KM_SLEEP
);
1283 oldsfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
1284 ASSERT(oldsfp
->hdr
.i8count
== 0);
1285 memcpy(buf
, oldsfp
, oldsize
);
1287 * Compute the new inode size.
1291 (oldsfp
->hdr
.count
+ 1) *
1292 ((uint
)sizeof(xfs_dir2_ino8_t
) - (uint
)sizeof(xfs_dir2_ino4_t
));
1293 xfs_idata_realloc(dp
, -oldsize
, XFS_DATA_FORK
);
1294 xfs_idata_realloc(dp
, newsize
, XFS_DATA_FORK
);
1296 * Reset our pointers, the data has moved.
1298 oldsfp
= (xfs_dir2_sf_t
*)buf
;
1299 sfp
= (xfs_dir2_sf_t
*)dp
->i_df
.if_u1
.if_data
;
1301 * Fill in the new header.
1303 sfp
->hdr
.count
= oldsfp
->hdr
.count
;
1304 sfp
->hdr
.i8count
= 1;
1305 xfs_dir2_sf_put_parent_ino(sfp
, xfs_dir2_sf_get_parent_ino(oldsfp
));
1307 * Copy the entries field by field.
1309 for (i
= 0, sfep
= xfs_dir2_sf_firstentry(sfp
),
1310 oldsfep
= xfs_dir2_sf_firstentry(oldsfp
);
1312 i
++, sfep
= xfs_dir2_sf_nextentry(sfp
, sfep
),
1313 oldsfep
= xfs_dir2_sf_nextentry(oldsfp
, oldsfep
)) {
1314 sfep
->namelen
= oldsfep
->namelen
;
1315 sfep
->offset
= oldsfep
->offset
;
1316 memcpy(sfep
->name
, oldsfep
->name
, sfep
->namelen
);
1317 xfs_dir2_sfe_put_ino(sfp
, sfep
,
1318 xfs_dir2_sfe_get_ino(oldsfp
, oldsfep
));
1321 * Clean up the inode.
1324 dp
->i_d
.di_size
= newsize
;
1325 xfs_trans_log_inode(args
->trans
, dp
, XFS_ILOG_CORE
| XFS_ILOG_DDATA
);
1327 #endif /* XFS_BIG_INUMS */