diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-10-30 03:04:13 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-10-30 03:04:13 -0400 |
commit | c679eef0520eb3c2c731fce505e61b8ef9469aac (patch) | |
tree | 6a3cdcb882282d10dac7bb45e194fc473dd3940d /fs | |
parent | 455486b9ccdd0a1d7432a03302f549b1c917c181 (diff) |
[XFS] stop using xfs_itobp in xfs_bulkstat
xfs_bulkstat only wants the dinode, offset and buffer from a given inode
number. Instead of using xfs_itobp on a fake inode which is complicated
and currently leads to leaks of the security data just use xfs_inotobp
which is designed to do exactly the kind of lookup xfs_bulkstat wants. The
only thing that's missing in xfs_inotobp is a flags paramter that let's us
pass down XFS_IMAP_BULKSTAT, but that can easily added.
SGI-PV: 987246
SGI-Modid: xfs-linux-melb:xfs-kern:32397a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: David Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_inode.c | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.h | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_itable.c | 21 |
3 files changed, 19 insertions, 21 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index c83f6998f95e..35e419191abf 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -222,25 +222,26 @@ xfs_imap_to_bp( | |||
222 | * Use xfs_imap() to determine the size and location of the | 222 | * Use xfs_imap() to determine the size and location of the |
223 | * buffer to read from disk. | 223 | * buffer to read from disk. |
224 | */ | 224 | */ |
225 | STATIC int | 225 | int |
226 | xfs_inotobp( | 226 | xfs_inotobp( |
227 | xfs_mount_t *mp, | 227 | xfs_mount_t *mp, |
228 | xfs_trans_t *tp, | 228 | xfs_trans_t *tp, |
229 | xfs_ino_t ino, | 229 | xfs_ino_t ino, |
230 | xfs_dinode_t **dipp, | 230 | xfs_dinode_t **dipp, |
231 | xfs_buf_t **bpp, | 231 | xfs_buf_t **bpp, |
232 | int *offset) | 232 | int *offset, |
233 | uint imap_flags) | ||
233 | { | 234 | { |
234 | xfs_imap_t imap; | 235 | xfs_imap_t imap; |
235 | xfs_buf_t *bp; | 236 | xfs_buf_t *bp; |
236 | int error; | 237 | int error; |
237 | 238 | ||
238 | imap.im_blkno = 0; | 239 | imap.im_blkno = 0; |
239 | error = xfs_imap(mp, tp, ino, &imap, XFS_IMAP_LOOKUP); | 240 | error = xfs_imap(mp, tp, ino, &imap, imap_flags | XFS_IMAP_LOOKUP); |
240 | if (error) | 241 | if (error) |
241 | return error; | 242 | return error; |
242 | 243 | ||
243 | error = xfs_imap_to_bp(mp, tp, &imap, &bp, XFS_BUF_LOCK, 0); | 244 | error = xfs_imap_to_bp(mp, tp, &imap, &bp, XFS_BUF_LOCK, imap_flags); |
244 | if (error) | 245 | if (error) |
245 | return error; | 246 | return error; |
246 | 247 | ||
@@ -792,7 +793,7 @@ xfs_dic2xflags( | |||
792 | /* | 793 | /* |
793 | * Allocate and initialise an xfs_inode. | 794 | * Allocate and initialise an xfs_inode. |
794 | */ | 795 | */ |
795 | struct xfs_inode * | 796 | STATIC struct xfs_inode * |
796 | xfs_inode_alloc( | 797 | xfs_inode_alloc( |
797 | struct xfs_mount *mp, | 798 | struct xfs_mount *mp, |
798 | xfs_ino_t ino) | 799 | xfs_ino_t ino) |
@@ -2046,7 +2047,7 @@ xfs_iunlink_remove( | |||
2046 | } | 2047 | } |
2047 | next_ino = XFS_AGINO_TO_INO(mp, agno, next_agino); | 2048 | next_ino = XFS_AGINO_TO_INO(mp, agno, next_agino); |
2048 | error = xfs_inotobp(mp, tp, next_ino, &last_dip, | 2049 | error = xfs_inotobp(mp, tp, next_ino, &last_dip, |
2049 | &last_ibp, &last_offset); | 2050 | &last_ibp, &last_offset, 0); |
2050 | if (error) { | 2051 | if (error) { |
2051 | cmn_err(CE_WARN, | 2052 | cmn_err(CE_WARN, |
2052 | "xfs_iunlink_remove: xfs_inotobp() returned an error %d on %s. Returning error.", | 2053 | "xfs_iunlink_remove: xfs_inotobp() returned an error %d on %s. Returning error.", |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index a5aeb9cfeae8..5d12cfeb43c5 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -158,7 +158,7 @@ typedef struct xfs_icdinode { | |||
158 | #define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */ | 158 | #define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */ |
159 | 159 | ||
160 | /* | 160 | /* |
161 | * Flags for xfs_itobp(), xfs_imap() and xfs_dilocate(). | 161 | * Flags for xfs_inotobp, xfs_itobp(), xfs_imap() and xfs_dilocate(). |
162 | */ | 162 | */ |
163 | #define XFS_IMAP_LOOKUP 0x1 | 163 | #define XFS_IMAP_LOOKUP 0x1 |
164 | #define XFS_IMAP_BULKSTAT 0x2 | 164 | #define XFS_IMAP_BULKSTAT 0x2 |
@@ -514,7 +514,6 @@ int xfs_itruncate_finish(struct xfs_trans **, xfs_inode_t *, | |||
514 | xfs_fsize_t, int, int); | 514 | xfs_fsize_t, int, int); |
515 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); | 515 | int xfs_iunlink(struct xfs_trans *, xfs_inode_t *); |
516 | 516 | ||
517 | struct xfs_inode * xfs_inode_alloc(struct xfs_mount *, xfs_ino_t); | ||
518 | void xfs_idestroy(xfs_inode_t *); | 517 | void xfs_idestroy(xfs_inode_t *); |
519 | void xfs_iextract(xfs_inode_t *); | 518 | void xfs_iextract(xfs_inode_t *); |
520 | void xfs_iext_realloc(xfs_inode_t *, int, int); | 519 | void xfs_iext_realloc(xfs_inode_t *, int, int); |
@@ -531,6 +530,9 @@ void xfs_mark_inode_dirty_sync(xfs_inode_t *); | |||
531 | 530 | ||
532 | #endif /* __KERNEL__ */ | 531 | #endif /* __KERNEL__ */ |
533 | 532 | ||
533 | int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, | ||
534 | xfs_ino_t, struct xfs_dinode **, | ||
535 | struct xfs_buf **, int *, uint); | ||
534 | int xfs_itobp(struct xfs_mount *, struct xfs_trans *, | 536 | int xfs_itobp(struct xfs_mount *, struct xfs_trans *, |
535 | struct xfs_inode *, struct xfs_dinode **, | 537 | struct xfs_inode *, struct xfs_dinode **, |
536 | struct xfs_buf **, xfs_daddr_t, uint, uint); | 538 | struct xfs_buf **, xfs_daddr_t, uint, uint); |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 42a214b8df9e..35118032a5d6 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -359,7 +359,6 @@ xfs_bulkstat( | |||
359 | int ubused; /* bytes used by formatter */ | 359 | int ubused; /* bytes used by formatter */ |
360 | xfs_buf_t *bp; /* ptr to on-disk inode cluster buf */ | 360 | xfs_buf_t *bp; /* ptr to on-disk inode cluster buf */ |
361 | xfs_dinode_t *dip; /* ptr into bp for specific inode */ | 361 | xfs_dinode_t *dip; /* ptr into bp for specific inode */ |
362 | xfs_inode_t *ip; /* ptr to in-core inode struct */ | ||
363 | 362 | ||
364 | /* | 363 | /* |
365 | * Get the last inode value, see if there's nothing to do. | 364 | * Get the last inode value, see if there's nothing to do. |
@@ -585,6 +584,8 @@ xfs_bulkstat( | |||
585 | 584 | ||
586 | if (flags & (BULKSTAT_FG_QUICK | | 585 | if (flags & (BULKSTAT_FG_QUICK | |
587 | BULKSTAT_FG_INLINE)) { | 586 | BULKSTAT_FG_INLINE)) { |
587 | int offset; | ||
588 | |||
588 | ino = XFS_AGINO_TO_INO(mp, agno, | 589 | ino = XFS_AGINO_TO_INO(mp, agno, |
589 | agino); | 590 | agino); |
590 | bno = XFS_AGB_TO_DADDR(mp, agno, | 591 | bno = XFS_AGB_TO_DADDR(mp, agno, |
@@ -595,19 +596,13 @@ xfs_bulkstat( | |||
595 | */ | 596 | */ |
596 | if (bp) | 597 | if (bp) |
597 | xfs_buf_relse(bp); | 598 | xfs_buf_relse(bp); |
598 | ip = xfs_inode_alloc(mp, ino); | 599 | |
599 | if (!ip) { | 600 | error = xfs_inotobp(mp, NULL, ino, &dip, |
600 | bp = NULL; | 601 | &bp, &offset, |
601 | rval = ENOMEM; | 602 | XFS_IMAP_BULKSTAT); |
602 | break; | 603 | |
603 | } | ||
604 | error = xfs_itobp(mp, NULL, ip, | ||
605 | &dip, &bp, bno, | ||
606 | XFS_IMAP_BULKSTAT, | ||
607 | XFS_BUF_LOCK); | ||
608 | if (!error) | 604 | if (!error) |
609 | clustidx = ip->i_boffset / mp->m_sb.sb_inodesize; | 605 | clustidx = offset / mp->m_sb.sb_inodesize; |
610 | xfs_idestroy(ip); | ||
611 | if (XFS_TEST_ERROR(error != 0, | 606 | if (XFS_TEST_ERROR(error != 0, |
612 | mp, XFS_ERRTAG_BULKSTAT_READ_CHUNK, | 607 | mp, XFS_ERRTAG_BULKSTAT_READ_CHUNK, |
613 | XFS_RANDOM_BULKSTAT_READ_CHUNK)) { | 608 | XFS_RANDOM_BULKSTAT_READ_CHUNK)) { |