Commit 7b6259e7a83647948fa33a736cc832310c8d85aa

Authored by Dave Chinner
Committed by Dave Chinner
1 parent 1920779e67

xfs: remove block number from inode lookup code

The block number comes from bulkstat based inode lookups to shortcut
the mapping calculations. We ar enot able to trust anything from
bulkstat, so drop the block number as well so that the correct
lookups and mappings are always done.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>

Showing 15 changed files with 26 additions and 59 deletions Side-by-side Diff

fs/xfs/linux-2.6/xfs_export.c
... ... @@ -133,7 +133,7 @@
133 133 * send invalid file handles and we have to handle it gracefully..
134 134 */
135 135 error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
136   - XFS_ILOCK_SHARED, &ip, 0);
  136 + XFS_ILOCK_SHARED, &ip);
137 137 if (error) {
138 138 /*
139 139 * EINVAL means the inode cluster doesn't exist anymore.
fs/xfs/linux-2.6/xfs_ioctl32.c
... ... @@ -237,12 +237,11 @@
237 237 xfs_ino_t ino, /* inode number to get data for */
238 238 void __user *buffer, /* buffer to place output in */
239 239 int ubsize, /* size of buffer */
240   - xfs_daddr_t bno, /* starting bno of inode cluster */
241 240 int *ubused, /* bytes used by me */
242 241 int *stat) /* BULKSTAT_RV_... */
243 242 {
244 243 return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
245   - xfs_bulkstat_one_fmt_compat, bno,
  244 + xfs_bulkstat_one_fmt_compat,
246 245 ubused, stat);
247 246 }
248 247  
... ... @@ -296,7 +295,7 @@
296 295 int res;
297 296  
298 297 error = xfs_bulkstat_one_compat(mp, inlast, bulkreq.ubuffer,
299   - sizeof(compat_xfs_bstat_t), 0, NULL, &res);
  298 + sizeof(compat_xfs_bstat_t), 0, &res);
300 299 } else if (cmd == XFS_IOC_FSBULKSTAT_32) {
301 300 error = xfs_bulkstat(mp, &inlast, &count,
302 301 xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t),
fs/xfs/quota/xfs_qm.c
... ... @@ -1632,7 +1632,6 @@
1632 1632 xfs_ino_t ino, /* inode number to get data for */
1633 1633 void __user *buffer, /* not used */
1634 1634 int ubsize, /* not used */
1635   - xfs_daddr_t bno, /* starting block of inode cluster */
1636 1635 int *ubused, /* not used */
1637 1636 int *res) /* result code value */
1638 1637 {
... ... @@ -1658,7 +1657,7 @@
1658 1657 * the case in all other instances. It's OK that we do this because
1659 1658 * quotacheck is done only at mount time.
1660 1659 */
1661   - if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip, bno))) {
  1660 + if ((error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_EXCL, &ip))) {
1662 1661 *res = BULKSTAT_RV_NOTHING;
1663 1662 return error;
1664 1663 }
1665 1664  
... ... @@ -1888,14 +1887,14 @@
1888 1887 mp->m_sb.sb_uquotino != NULLFSINO) {
1889 1888 ASSERT(mp->m_sb.sb_uquotino > 0);
1890 1889 if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
1891   - 0, 0, &uip, 0)))
  1890 + 0, 0, &uip)))
1892 1891 return XFS_ERROR(error);
1893 1892 }
1894 1893 if (XFS_IS_OQUOTA_ON(mp) &&
1895 1894 mp->m_sb.sb_gquotino != NULLFSINO) {
1896 1895 ASSERT(mp->m_sb.sb_gquotino > 0);
1897 1896 if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
1898   - 0, 0, &gip, 0))) {
  1897 + 0, 0, &gip))) {
1899 1898 if (uip)
1900 1899 IRELE(uip);
1901 1900 return XFS_ERROR(error);
fs/xfs/quota/xfs_qm_syscalls.c
... ... @@ -262,7 +262,7 @@
262 262 }
263 263  
264 264 if ((flags & XFS_DQ_USER) && mp->m_sb.sb_uquotino != NULLFSINO) {
265   - error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip, 0);
  265 + error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 0, 0, &qip);
266 266 if (!error) {
267 267 error = xfs_truncate_file(mp, qip);
268 268 IRELE(qip);
... ... @@ -271,7 +271,7 @@
271 271  
272 272 if ((flags & (XFS_DQ_GROUP|XFS_DQ_PROJ)) &&
273 273 mp->m_sb.sb_gquotino != NULLFSINO) {
274   - error2 = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip, 0);
  274 + error2 = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip);
275 275 if (!error2) {
276 276 error2 = xfs_truncate_file(mp, qip);
277 277 IRELE(qip);
278 278  
... ... @@ -417,12 +417,12 @@
417 417 }
418 418 if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) {
419 419 if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
420   - 0, 0, &uip, 0) == 0)
  420 + 0, 0, &uip) == 0)
421 421 tempuqip = B_TRUE;
422 422 }
423 423 if (!gip && mp->m_sb.sb_gquotino != NULLFSINO) {
424 424 if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
425   - 0, 0, &gip, 0) == 0)
  425 + 0, 0, &gip) == 0)
426 426 tempgqip = B_TRUE;
427 427 }
428 428 if (uip) {
... ... @@ -1109,7 +1109,6 @@
1109 1109 xfs_ino_t ino, /* inode number to get data for */
1110 1110 void __user *buffer, /* not used */
1111 1111 int ubsize, /* not used */
1112   - xfs_daddr_t bno, /* starting block of inode cluster */
1113 1112 int *ubused, /* not used */
1114 1113 int *res) /* bulkstat result code */
1115 1114 {
... ... @@ -1132,7 +1131,7 @@
1132 1131 ipreleased = B_FALSE;
1133 1132 again:
1134 1133 lock_flags = XFS_ILOCK_SHARED;
1135   - if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip, bno))) {
  1134 + if ((error = xfs_iget(mp, NULL, ino, 0, lock_flags, &ip))) {
1136 1135 *res = BULKSTAT_RV_NOTHING;
1137 1136 return (error);
1138 1137 }
... ... @@ -1355,22 +1355,6 @@
1355 1355 }
1356 1356  
1357 1357 /*
1358   - * If we get a block number passed we can use it to
1359   - * find the buffer easily.
1360   - */
1361   - if (imap->im_blkno) {
1362   - offset = XFS_INO_TO_OFFSET(mp, ino);
1363   - ASSERT(offset < mp->m_sb.sb_inopblock);
1364   -
1365   - cluster_agbno = xfs_daddr_to_agbno(mp, imap->im_blkno);
1366   - offset += (agbno - cluster_agbno) * mp->m_sb.sb_inopblock;
1367   -
1368   - imap->im_len = XFS_FSB_TO_BB(mp, blks_per_cluster);
1369   - imap->im_boffset = (ushort)(offset << mp->m_sb.sb_inodelog);
1370   - return 0;
1371   - }
1372   -
1373   - /*
1374 1358 * If the inode chunks are aligned then use simple maths to
1375 1359 * find the location. Otherwise we have to do a btree
1376 1360 * lookup to find the location.
... ... @@ -259,7 +259,6 @@
259 259 xfs_trans_t *tp,
260 260 xfs_ino_t ino,
261 261 struct xfs_inode **ipp,
262   - xfs_daddr_t bno,
263 262 int flags,
264 263 int lock_flags)
265 264 {
... ... @@ -272,7 +271,7 @@
272 271 if (!ip)
273 272 return ENOMEM;
274 273  
275   - error = xfs_iread(mp, tp, ip, bno, flags);
  274 + error = xfs_iread(mp, tp, ip, flags);
276 275 if (error)
277 276 goto out_destroy;
278 277  
... ... @@ -358,8 +357,6 @@
358 357 * within the file system for the inode being requested.
359 358 * lock_flags -- flags indicating how to lock the inode. See the comment
360 359 * for xfs_ilock() for a list of valid values.
361   - * bno -- the block number starting the buffer containing the inode,
362   - * if known (as by bulkstat), else 0.
363 360 */
364 361 int
365 362 xfs_iget(
... ... @@ -368,8 +365,7 @@
368 365 xfs_ino_t ino,
369 366 uint flags,
370 367 uint lock_flags,
371   - xfs_inode_t **ipp,
372   - xfs_daddr_t bno)
  368 + xfs_inode_t **ipp)
373 369 {
374 370 xfs_inode_t *ip;
375 371 int error;
... ... @@ -397,7 +393,7 @@
397 393 read_unlock(&pag->pag_ici_lock);
398 394 XFS_STATS_INC(xs_ig_missed);
399 395  
400   - error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip, bno,
  396 + error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip,
401 397 flags, lock_flags);
402 398 if (error)
403 399 goto out_error_or_again;
... ... @@ -787,7 +787,6 @@
787 787 xfs_mount_t *mp,
788 788 xfs_trans_t *tp,
789 789 xfs_inode_t *ip,
790   - xfs_daddr_t bno,
791 790 uint iget_flags)
792 791 {
793 792 xfs_buf_t *bp;
794 793  
... ... @@ -797,11 +796,9 @@
797 796 /*
798 797 * Fill in the location information in the in-core inode.
799 798 */
800   - ip->i_imap.im_blkno = bno;
801 799 error = xfs_imap(mp, tp, ip->i_ino, &ip->i_imap, iget_flags);
802 800 if (error)
803 801 return error;
804   - ASSERT(bno == 0 || bno == ip->i_imap.im_blkno);
805 802  
806 803 /*
807 804 * Get pointers to the on-disk inode and the buffer containing it.
... ... @@ -442,7 +442,7 @@
442 442 * xfs_iget.c prototypes.
443 443 */
444 444 int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
445   - uint, uint, xfs_inode_t **, xfs_daddr_t);
  445 + uint, uint, xfs_inode_t **);
446 446 void xfs_iput(xfs_inode_t *, uint);
447 447 void xfs_iput_new(xfs_inode_t *, uint);
448 448 void xfs_ilock(xfs_inode_t *, uint);
... ... @@ -509,7 +509,7 @@
509 509 struct xfs_inode *, struct xfs_dinode **,
510 510 struct xfs_buf **, uint);
511 511 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
512   - struct xfs_inode *, xfs_daddr_t, uint);
  512 + struct xfs_inode *, uint);
513 513 void xfs_dinode_to_disk(struct xfs_dinode *,
514 514 struct xfs_icdinode *);
515 515 void xfs_idestroy_fork(struct xfs_inode *, int);
... ... @@ -60,7 +60,6 @@
60 60 void __user *buffer, /* buffer to place output in */
61 61 int ubsize, /* size of buffer */
62 62 bulkstat_one_fmt_pf formatter, /* formatter, copy to user */
63   - xfs_daddr_t bno, /* starting bno of cluster */
64 63 int *ubused, /* bytes used by me */
65 64 int *stat) /* BULKSTAT_RV_... */
66 65 {
... ... @@ -80,7 +79,7 @@
80 79 return XFS_ERROR(ENOMEM);
81 80  
82 81 error = xfs_iget(mp, NULL, ino,
83   - XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip, bno);
  82 + XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip);
84 83 if (error) {
85 84 *stat = BULKSTAT_RV_NOTHING;
86 85 goto out_free;
87 86  
... ... @@ -179,13 +178,11 @@
179 178 xfs_ino_t ino, /* inode number to get data for */
180 179 void __user *buffer, /* buffer to place output in */
181 180 int ubsize, /* size of buffer */
182   - xfs_daddr_t bno, /* starting bno of inode cluster */
183 181 int *ubused, /* bytes used by me */
184 182 int *stat) /* BULKSTAT_RV_... */
185 183 {
186 184 return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
187   - xfs_bulkstat_one_fmt, bno,
188   - ubused, stat);
  185 + xfs_bulkstat_one_fmt, ubused, stat);
189 186 }
190 187  
191 188 #define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size)
... ... @@ -485,7 +482,7 @@
485 482 * Get the inode and fill in a single buffer.
486 483 */
487 484 ubused = statstruct_size;
488   - error = formatter(mp, ino, ubufp, ubleft, bno,
  485 + error = formatter(mp, ino, ubufp, ubleft,
489 486 &ubused, &fmterror);
490 487 if (fmterror == BULKSTAT_RV_NOTHING) {
491 488 if (error && error != ENOENT &&
... ... @@ -578,8 +575,7 @@
578 575 */
579 576  
580 577 ino = (xfs_ino_t)*lastinop;
581   - error = xfs_bulkstat_one(mp, ino, buffer, sizeof(xfs_bstat_t),
582   - 0, NULL, &res);
  578 + error = xfs_bulkstat_one(mp, ino, buffer, sizeof(xfs_bstat_t), 0, &res);
583 579 if (error) {
584 580 /*
585 581 * Special case way failed, do it the "long" way
... ... @@ -27,7 +27,6 @@
27 27 xfs_ino_t ino,
28 28 void __user *buffer,
29 29 int ubsize,
30   - xfs_daddr_t bno,
31 30 int *ubused,
32 31 int *stat);
33 32  
... ... @@ -71,7 +70,6 @@
71 70 void __user *buffer,
72 71 int ubsize,
73 72 bulkstat_one_fmt_pf formatter,
74   - xfs_daddr_t bno,
75 73 int *ubused,
76 74 int *stat);
77 75  
... ... @@ -81,7 +79,6 @@
81 79 xfs_ino_t ino,
82 80 void __user *buffer,
83 81 int ubsize,
84   - xfs_daddr_t bno,
85 82 int *ubused,
86 83 int *stat);
87 84  
fs/xfs/xfs_log_recover.c
... ... @@ -3198,7 +3198,7 @@
3198 3198 int error;
3199 3199  
3200 3200 ino = XFS_AGINO_TO_INO(mp, agno, agino);
3201   - error = xfs_iget(mp, NULL, ino, 0, 0, &ip, 0);
  3201 + error = xfs_iget(mp, NULL, ino, 0, 0, &ip);
3202 3202 if (error)
3203 3203 goto fail;
3204 3204  
... ... @@ -1300,7 +1300,7 @@
1300 1300 * Get and sanity-check the root inode.
1301 1301 * Save the pointer to it in the mount structure.
1302 1302 */
1303   - error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip, 0);
  1303 + error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip);
1304 1304 if (error) {
1305 1305 cmn_err(CE_WARN, "XFS: failed to read root inode");
1306 1306 goto out_log_dealloc;
fs/xfs/xfs_rtalloc.c
... ... @@ -2277,12 +2277,12 @@
2277 2277 sbp = &mp->m_sb;
2278 2278 if (sbp->sb_rbmino == NULLFSINO)
2279 2279 return 0;
2280   - error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, 0, &mp->m_rbmip, 0);
  2280 + error = xfs_iget(mp, NULL, sbp->sb_rbmino, 0, 0, &mp->m_rbmip);
2281 2281 if (error)
2282 2282 return error;
2283 2283 ASSERT(mp->m_rbmip != NULL);
2284 2284 ASSERT(sbp->sb_rsumino != NULLFSINO);
2285   - error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip, 0);
  2285 + error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip);
2286 2286 if (error) {
2287 2287 IRELE(mp->m_rbmip);
2288 2288 return error;
fs/xfs/xfs_trans_inode.c
... ... @@ -62,7 +62,7 @@
62 62 {
63 63 int error;
64 64  
65   - error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp, 0);
  65 + error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp);
66 66 if (!error && tp)
67 67 xfs_trans_ijoin(tp, *ipp, lock_flags);
68 68 return error;
fs/xfs/xfs_vnodeops.c
... ... @@ -1269,7 +1269,7 @@
1269 1269 if (error)
1270 1270 goto out;
1271 1271  
1272   - error = xfs_iget(dp->i_mount, NULL, inum, 0, 0, ipp, 0);
  1272 + error = xfs_iget(dp->i_mount, NULL, inum, 0, 0, ipp);
1273 1273 if (error)
1274 1274 goto out_free_name;
1275 1275