Skip to content

Commit 7b6259e

Browse files
dgchinnerdchinner
authored andcommitted
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>
1 parent 1920779 commit 7b6259e

15 files changed

Lines changed: 26 additions & 59 deletions

‎fs/xfs/linux-2.6/xfs_export.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ xfs_nfs_get_inode(
133133
* send invalid file handles and we have to handle it gracefully..
134134
*/
135135
error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED,
136-
XFS_ILOCK_SHARED, &ip, 0);
136+
XFS_ILOCK_SHARED, &ip);
137137
if (error) {
138138
/*
139139
* EINVAL means the inode cluster doesn't exist anymore.

‎fs/xfs/linux-2.6/xfs_ioctl32.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,11 @@ xfs_bulkstat_one_compat(
237237
xfs_ino_t ino, /* inode number to get data for */
238238
void __user *buffer, /* buffer to place output in */
239239
int ubsize, /* size of buffer */
240-
xfs_daddr_t bno, /* starting bno of inode cluster */
241240
int *ubused, /* bytes used by me */
242241
int *stat) /* BULKSTAT_RV_... */
243242
{
244243
return xfs_bulkstat_one_int(mp, ino, buffer, ubsize,
245-
xfs_bulkstat_one_fmt_compat, bno,
244+
xfs_bulkstat_one_fmt_compat,
246245
ubused, stat);
247246
}
248247

@@ -296,7 +295,7 @@ xfs_compat_ioc_bulkstat(
296295
int res;
297296

298297
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);
300299
} else if (cmd == XFS_IOC_FSBULKSTAT_32) {
301300
error = xfs_bulkstat(mp, &inlast, &count,
302301
xfs_bulkstat_one_compat, sizeof(compat_xfs_bstat_t),

‎fs/xfs/quota/xfs_qm.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,6 @@ xfs_qm_dqusage_adjust(
16321632
xfs_ino_t ino, /* inode number to get data for */
16331633
void __user *buffer, /* not used */
16341634
int ubsize, /* not used */
1635-
xfs_daddr_t bno, /* starting block of inode cluster */
16361635
int *ubused, /* not used */
16371636
int *res) /* result code value */
16381637
{
@@ -1658,7 +1657,7 @@ xfs_qm_dqusage_adjust(
16581657
* the case in all other instances. It's OK that we do this because
16591658
* quotacheck is done only at mount time.
16601659
*/
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))) {
16621661
*res = BULKSTAT_RV_NOTHING;
16631662
return error;
16641663
}
@@ -1888,14 +1887,14 @@ xfs_qm_init_quotainos(
18881887
mp->m_sb.sb_uquotino != NULLFSINO) {
18891888
ASSERT(mp->m_sb.sb_uquotino > 0);
18901889
if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
1891-
0, 0, &uip, 0)))
1890+
0, 0, &uip)))
18921891
return XFS_ERROR(error);
18931892
}
18941893
if (XFS_IS_OQUOTA_ON(mp) &&
18951894
mp->m_sb.sb_gquotino != NULLFSINO) {
18961895
ASSERT(mp->m_sb.sb_gquotino > 0);
18971896
if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
1898-
0, 0, &gip, 0))) {
1897+
0, 0, &gip))) {
18991898
if (uip)
19001899
IRELE(uip);
19011900
return XFS_ERROR(error);

‎fs/xfs/quota/xfs_qm_syscalls.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ xfs_qm_scall_trunc_qfiles(
262262
}
263263

264264
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);
266266
if (!error) {
267267
error = xfs_truncate_file(mp, qip);
268268
IRELE(qip);
@@ -271,7 +271,7 @@ xfs_qm_scall_trunc_qfiles(
271271

272272
if ((flags & (XFS_DQ_GROUP|XFS_DQ_PROJ)) &&
273273
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);
275275
if (!error2) {
276276
error2 = xfs_truncate_file(mp, qip);
277277
IRELE(qip);
@@ -417,12 +417,12 @@ xfs_qm_scall_getqstat(
417417
}
418418
if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) {
419419
if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
420-
0, 0, &uip, 0) == 0)
420+
0, 0, &uip) == 0)
421421
tempuqip = B_TRUE;
422422
}
423423
if (!gip && mp->m_sb.sb_gquotino != NULLFSINO) {
424424
if (xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
425-
0, 0, &gip, 0) == 0)
425+
0, 0, &gip) == 0)
426426
tempgqip = B_TRUE;
427427
}
428428
if (uip) {
@@ -1109,7 +1109,6 @@ xfs_qm_internalqcheck_adjust(
11091109
xfs_ino_t ino, /* inode number to get data for */
11101110
void __user *buffer, /* not used */
11111111
int ubsize, /* not used */
1112-
xfs_daddr_t bno, /* starting block of inode cluster */
11131112
int *ubused, /* not used */
11141113
int *res) /* bulkstat result code */
11151114
{
@@ -1132,7 +1131,7 @@ xfs_qm_internalqcheck_adjust(
11321131
ipreleased = B_FALSE;
11331132
again:
11341133
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))) {
11361135
*res = BULKSTAT_RV_NOTHING;
11371136
return (error);
11381137
}

‎fs/xfs/xfs_ialloc.c‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,22 +1354,6 @@ xfs_imap(
13541354
return 0;
13551355
}
13561356

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-
13731357
/*
13741358
* If the inode chunks are aligned then use simple maths to
13751359
* find the location. Otherwise we have to do a btree

‎fs/xfs/xfs_iget.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ xfs_iget_cache_miss(
259259
xfs_trans_t *tp,
260260
xfs_ino_t ino,
261261
struct xfs_inode **ipp,
262-
xfs_daddr_t bno,
263262
int flags,
264263
int lock_flags)
265264
{
@@ -272,7 +271,7 @@ xfs_iget_cache_miss(
272271
if (!ip)
273272
return ENOMEM;
274273

275-
error = xfs_iread(mp, tp, ip, bno, flags);
274+
error = xfs_iread(mp, tp, ip, flags);
276275
if (error)
277276
goto out_destroy;
278277

@@ -358,8 +357,6 @@ xfs_iget_cache_miss(
358357
* within the file system for the inode being requested.
359358
* lock_flags -- flags indicating how to lock the inode. See the comment
360359
* 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.
363360
*/
364361
int
365362
xfs_iget(
@@ -368,8 +365,7 @@ xfs_iget(
368365
xfs_ino_t ino,
369366
uint flags,
370367
uint lock_flags,
371-
xfs_inode_t **ipp,
372-
xfs_daddr_t bno)
368+
xfs_inode_t **ipp)
373369
{
374370
xfs_inode_t *ip;
375371
int error;
@@ -397,7 +393,7 @@ xfs_iget(
397393
read_unlock(&pag->pag_ici_lock);
398394
XFS_STATS_INC(xs_ig_missed);
399395

400-
error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip, bno,
396+
error = xfs_iget_cache_miss(mp, pag, tp, ino, &ip,
401397
flags, lock_flags);
402398
if (error)
403399
goto out_error_or_again;

‎fs/xfs/xfs_inode.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ xfs_iread(
787787
xfs_mount_t *mp,
788788
xfs_trans_t *tp,
789789
xfs_inode_t *ip,
790-
xfs_daddr_t bno,
791790
uint iget_flags)
792791
{
793792
xfs_buf_t *bp;
@@ -797,11 +796,9 @@ xfs_iread(
797796
/*
798797
* Fill in the location information in the in-core inode.
799798
*/
800-
ip->i_imap.im_blkno = bno;
801799
error = xfs_imap(mp, tp, ip->i_ino, &ip->i_imap, iget_flags);
802800
if (error)
803801
return error;
804-
ASSERT(bno == 0 || bno == ip->i_imap.im_blkno);
805802

806803
/*
807804
* Get pointers to the on-disk inode and the buffer containing it.

‎fs/xfs/xfs_inode.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static inline void xfs_ifunlock(xfs_inode_t *ip)
442442
* xfs_iget.c prototypes.
443443
*/
444444
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 **);
446446
void xfs_iput(xfs_inode_t *, uint);
447447
void xfs_iput_new(xfs_inode_t *, uint);
448448
void xfs_ilock(xfs_inode_t *, uint);
@@ -509,7 +509,7 @@ int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
509509
struct xfs_inode *, struct xfs_dinode **,
510510
struct xfs_buf **, uint);
511511
int xfs_iread(struct xfs_mount *, struct xfs_trans *,
512-
struct xfs_inode *, xfs_daddr_t, uint);
512+
struct xfs_inode *, uint);
513513
void xfs_dinode_to_disk(struct xfs_dinode *,
514514
struct xfs_icdinode *);
515515
void xfs_idestroy_fork(struct xfs_inode *, int);

‎fs/xfs/xfs_itable.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ xfs_bulkstat_one_int(
6060
void __user *buffer, /* buffer to place output in */
6161
int ubsize, /* size of buffer */
6262
bulkstat_one_fmt_pf formatter, /* formatter, copy to user */
63-
xfs_daddr_t bno, /* starting bno of cluster */
6463
int *ubused, /* bytes used by me */
6564
int *stat) /* BULKSTAT_RV_... */
6665
{
@@ -80,7 +79,7 @@ xfs_bulkstat_one_int(
8079
return XFS_ERROR(ENOMEM);
8180

8281
error = xfs_iget(mp, NULL, ino,
83-
XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip, bno);
82+
XFS_IGET_UNTRUSTED, XFS_ILOCK_SHARED, &ip);
8483
if (error) {
8584
*stat = BULKSTAT_RV_NOTHING;
8685
goto out_free;
@@ -179,13 +178,11 @@ xfs_bulkstat_one(
179178
xfs_ino_t ino, /* inode number to get data for */
180179
void __user *buffer, /* buffer to place output in */
181180
int ubsize, /* size of buffer */
182-
xfs_daddr_t bno, /* starting bno of inode cluster */
183181
int *ubused, /* bytes used by me */
184182
int *stat) /* BULKSTAT_RV_... */
185183
{
186184
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);
189186
}
190187

191188
#define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size)
@@ -485,7 +482,7 @@ xfs_bulkstat(
485482
* Get the inode and fill in a single buffer.
486483
*/
487484
ubused = statstruct_size;
488-
error = formatter(mp, ino, ubufp, ubleft, bno,
485+
error = formatter(mp, ino, ubufp, ubleft,
489486
&ubused, &fmterror);
490487
if (fmterror == BULKSTAT_RV_NOTHING) {
491488
if (error && error != ENOENT &&
@@ -578,8 +575,7 @@ xfs_bulkstat_single(
578575
*/
579576

580577
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);
583579
if (error) {
584580
/*
585581
* Special case way failed, do it the "long" way

‎fs/xfs/xfs_itable.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ typedef int (*bulkstat_one_pf)(struct xfs_mount *mp,
2727
xfs_ino_t ino,
2828
void __user *buffer,
2929
int ubsize,
30-
xfs_daddr_t bno,
3130
int *ubused,
3231
int *stat);
3332

@@ -71,7 +70,6 @@ xfs_bulkstat_one_int(
7170
void __user *buffer,
7271
int ubsize,
7372
bulkstat_one_fmt_pf formatter,
74-
xfs_daddr_t bno,
7573
int *ubused,
7674
int *stat);
7775

@@ -81,7 +79,6 @@ xfs_bulkstat_one(
8179
xfs_ino_t ino,
8280
void __user *buffer,
8381
int ubsize,
84-
xfs_daddr_t bno,
8582
int *ubused,
8683
int *stat);
8784

0 commit comments

Comments
 (0)