diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index dcd2f93b6a6c..6cab66781d66 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -863,32 +863,30 @@ xfs_ag_shrink_space( return err2; } -void -xfs_growfs_compute_deltas( +/* + * Return the agcount for the new file system size passed in *nb and adjust *nb + * when it has to be reduced because of maximum AG count or because it would + * create a below minimum size AG. + */ +xfs_agnumber_t +xfs_growfs_compute_agcount( struct xfs_mount *mp, - xfs_rfsblock_t nb, - int64_t *deltap, - xfs_agnumber_t *nagcountp) + xfs_rfsblock_t *nb) { - xfs_rfsblock_t nb_div, nb_mod; - int64_t delta; - xfs_agnumber_t nagcount; + uint64_t agcount; /* 64-bits wide to catch overflows */ + xfs_extlen_t remainder; - nb_div = nb; - nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks); - if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS) - nb_div++; - else if (nb_mod) - nb = nb_div * mp->m_sb.sb_agblocks; - - if (nb_div > XFS_MAX_AGNUMBER + 1) { - nb_div = XFS_MAX_AGNUMBER + 1; - nb = nb_div * mp->m_sb.sb_agblocks; + agcount = div_u64_rem(*nb, mp->m_sb.sb_agblocks, &remainder); + if (agcount >= XFS_MAX_AGNUMBER + 1) { + agcount = XFS_MAX_AGNUMBER + 1; + remainder = 0; } - nagcount = nb_div; - delta = nb - mp->m_sb.sb_dblocks; - *deltap = delta; - *nagcountp = nagcount; + *nb = (xfs_rfsblock_t)agcount * mp->m_sb.sb_agblocks; + if (remainder >= XFS_MIN_AG_BLOCKS) { + *nb += remainder; + agcount++; + } + return agcount; } /* diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h index 16a9b43a3c27..fd22fe598931 100644 --- a/fs/xfs/libxfs/xfs_ag.h +++ b/fs/xfs/libxfs/xfs_ag.h @@ -329,12 +329,11 @@ struct aghdr_init_data { int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id); int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp, xfs_extlen_t delta); -void -xfs_growfs_compute_deltas(struct xfs_mount *mp, xfs_rfsblock_t nb, - int64_t *deltap, xfs_agnumber_t *nagcountp); int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp, xfs_extlen_t len); int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo); +xfs_agnumber_t xfs_growfs_compute_agcount(struct xfs_mount *mp, + xfs_rfsblock_t *nb); static inline xfs_fsblock_t xfs_agbno_to_fsb( diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 93caa1dae501..b3f7b2c34ad7 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -276,7 +276,7 @@ xfs_attr_get( return -EIO; if (!args->owner) - args->owner = args->dp->i_ino; + args->owner = I_INO(args->dp); args->geo = args->dp->i_mount->m_attr_geo; args->whichfork = XFS_ATTR_FORK; xfs_attr_sethash(args); diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 2b78041e8672..86c5c09a5db4 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -1429,7 +1429,7 @@ xfs_attr3_leaf_init( struct xfs_da_args args = { .trans = tp, .dp = dp, - .owner = dp->i_ino, + .owner = I_INO(dp), .geo = dp->i_mount->m_attr_geo, }; diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 7a4c8f1aa76c..d64defeda645 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -602,7 +602,7 @@ xfs_bmap_btree_to_extents( if ((error = xfs_btree_check_block(cur, cblock, 0, cbp))) return error; - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, ip, whichfork); error = xfs_free_extent_later(cur->bc_tp, cbno, 1, &oinfo, XFS_AG_RESV_NONE, 0); if (error) @@ -676,13 +676,12 @@ xfs_bmap_extents_to_btree( memset(&args, 0, sizeof(args)); args.tp = tp; args.mp = mp; - xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, whichfork); + xfs_rmap_inode_bmbt_owner(&args.oinfo, ip, whichfork); args.minlen = args.maxlen = args.prod = 1; args.wasdel = wasdel; *logflagsp = 0; - error = xfs_alloc_vextent_start_ag(&args, - XFS_INO_TO_FSB(mp, ip->i_ino)); + error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip)); if (error) goto out_root_realloc; @@ -820,7 +819,7 @@ xfs_bmap_local_to_extents( args.mp = ip->i_mount; args.total = total; args.minlen = args.maxlen = args.prod = 1; - xfs_rmap_ino_owner(&args.oinfo, ip->i_ino, whichfork, 0); + xfs_rmap_inode_owner(&args.oinfo, ip, whichfork, 0); /* * Allocate a block. We know we need only one, since the @@ -828,8 +827,7 @@ xfs_bmap_local_to_extents( */ args.total = total; args.minlen = args.maxlen = args.prod = 1; - error = xfs_alloc_vextent_start_ag(&args, - XFS_INO_TO_FSB(args.mp, ip->i_ino)); + error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip)); if (error) goto done; @@ -976,7 +974,7 @@ xfs_bmap_add_attrfork_local( dargs.total = dargs.geo->fsbcount; dargs.whichfork = XFS_DATA_FORK; dargs.trans = tp; - dargs.owner = ip->i_ino; + dargs.owner = I_INO(ip); return xfs_dir2_sf_to_block(&dargs); } @@ -1110,7 +1108,7 @@ xfs_bmap_complain_bad_rec( xfs_warn(mp, "Bmap BTree record corruption in inode 0x%llx %s fork detected at %pS!", - ip->i_ino, forkname, fa); + I_INO(ip), forkname, fa); xfs_warn(mp, "Offset 0x%llx, start block 0x%llx, block count 0x%llx state 0x%x", irec->br_startoff, irec->br_startblock, irec->br_blockcount, @@ -1143,7 +1141,7 @@ xfs_iread_bmbt_block( num_recs = xfs_btree_get_numrecs(block); if (unlikely(ir->loaded + num_recs > ifp->if_nextents)) { xfs_warn(ip->i_mount, "corrupt dinode %llu, (btree extents).", - (unsigned long long)ip->i_ino); + (unsigned long long)I_INO(ip)); xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, block, sizeof(*block), __this_address); xfs_bmap_mark_sick(ip, whichfork); @@ -3590,7 +3588,7 @@ xfs_bmap_btalloc_best_length( xfs_extlen_t blen = 0; int error; - ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino); + ap->blkno = XFS_INODE_TO_FSB(ap->ip); if (!xfs_bmap_adjacent(ap)) ap->eof = false; diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c index 1c7165df483a..758a4b1ccf5b 100644 --- a/fs/xfs/libxfs/xfs_bmap_btree.c +++ b/fs/xfs/libxfs/xfs_bmap_btree.c @@ -36,10 +36,10 @@ xfs_bmbt_init_block( { if (bp) xfs_btree_init_buf(ip->i_mount, bp, &xfs_bmbt_ops, level, - numrecs, ip->i_ino); + numrecs, I_INO(ip)); else xfs_btree_init_block(ip->i_mount, buf, &xfs_bmbt_ops, level, - numrecs, ip->i_ino); + numrecs, I_INO(ip)); } /* @@ -217,7 +217,7 @@ xfs_bmbt_alloc_block( memset(&args, 0, sizeof(args)); args.tp = cur->bc_tp; args.mp = cur->bc_mp; - xfs_rmap_ino_bmbt_owner(&args.oinfo, cur->bc_ino.ip->i_ino, + xfs_rmap_inode_bmbt_owner(&args.oinfo, cur->bc_ino.ip, cur->bc_ino.whichfork); args.minlen = args.maxlen = args.prod = 1; args.wasdel = cur->bc_flags & XFS_BTREE_BMBT_WASDEL; @@ -280,7 +280,7 @@ xfs_bmbt_free_block( struct xfs_owner_info oinfo; int error; - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, ip, cur->bc_ino.whichfork); error = xfs_free_extent_later(cur->bc_tp, fsbno, 1, &oinfo, XFS_AG_RESV_NONE, 0); if (error) diff --git a/fs/xfs/libxfs/xfs_bmap_btree.h b/fs/xfs/libxfs/xfs_bmap_btree.h index b238d559ab03..e0c870beaf67 100644 --- a/fs/xfs/libxfs/xfs_bmap_btree.h +++ b/fs/xfs/libxfs/xfs_bmap_btree.h @@ -89,7 +89,7 @@ xfs_bmbt_key_addr( { return (struct xfs_bmbt_key *) ((char *)block + xfs_bmbt_block_len(mp) + - (index - 1) * sizeof(struct xfs_bmbt_key *)); + (index - 1) * sizeof(struct xfs_bmbt_key)); } static inline xfs_bmbt_ptr_t * diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 7012f3570c8d..60ef7f08b1d3 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -371,7 +371,7 @@ xfs_btree_check_ptr( case XFS_BTREE_TYPE_INODE: xfs_err(cur->bc_mp, "Inode %llu fork %d: Corrupt %sbt pointer at level %d index %d.", - cur->bc_ino.ip->i_ino, + I_INO(cur->bc_ino.ip), cur->bc_ino.whichfork, cur->bc_ops->name, level, index); break; @@ -1305,7 +1305,7 @@ xfs_btree_owner( case XFS_BTREE_TYPE_MEM: return cur->bc_mem.xfbtree->owner; case XFS_BTREE_TYPE_INODE: - return cur->bc_ino.ip->i_ino; + return I_INO(cur->bc_ino.ip); case XFS_BTREE_TYPE_AG: return cur->bc_group->xg_gno; default: @@ -3129,7 +3129,7 @@ xfs_btree_promote_leaf_iroot( */ broot = cur->bc_ops->broot_realloc(cur, 1); xfs_btree_init_block(cur->bc_mp, broot, cur->bc_ops, - cur->bc_nlevels - 1, 1, cur->bc_ino.ip->i_ino); + cur->bc_nlevels - 1, 1, I_INO(cur->bc_ino.ip)); pp = xfs_btree_ptr_addr(cur, 1, broot); kp = xfs_btree_key_addr(cur, 1, broot); @@ -3243,8 +3243,7 @@ xfs_btree_new_iroot( if (level > 0) aptr = *xfs_btree_ptr_addr(cur, 1, block); else - aptr.l = cpu_to_be64(XFS_INO_TO_FSB(cur->bc_mp, - cur->bc_ino.ip->i_ino)); + aptr.l = cpu_to_be64(XFS_INODE_TO_FSB(cur->bc_ino.ip)); /* Allocate the new block. If we can't do it, we're toast. Give up. */ error = xfs_btree_alloc_block(cur, &aptr, &nptr, stat); @@ -3827,7 +3826,7 @@ xfs_btree_demote_leaf_child( */ broot = cur->bc_ops->broot_realloc(cur, numrecs); xfs_btree_init_block(cur->bc_mp, broot, cur->bc_ops, 0, numrecs, - cur->bc_ino.ip->i_ino); + I_INO(cur->bc_ino.ip)); rp = xfs_btree_rec_addr(cur, 1, broot); crp = xfs_btree_rec_addr(cur, 1, cblock); @@ -5608,9 +5607,8 @@ xfs_btree_alloc_metafile_block( ASSERT(xfs_is_metadir_inode(ip)); - xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, cur->bc_ino.whichfork); - error = xfs_alloc_vextent_start_ag(&args, - XFS_INO_TO_FSB(cur->bc_mp, ip->i_ino)); + xfs_rmap_inode_bmbt_owner(&args.oinfo, ip, cur->bc_ino.whichfork); + error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip)); if (error) return error; if (args.fsbno == NULLFSBLOCK) { @@ -5641,7 +5639,7 @@ xfs_btree_free_metafile_block( ASSERT(xfs_is_metadir_inode(ip)); - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, cur->bc_ino.whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, ip, cur->bc_ino.whichfork); error = xfs_free_extent_later(tp, fsbno, 1, &oinfo, XFS_AG_RESV_METAFILE, 0); if (error) diff --git a/fs/xfs/libxfs/xfs_btree_staging.c b/fs/xfs/libxfs/xfs_btree_staging.c index 4300c058807b..c3c7ea54895a 100644 --- a/fs/xfs/libxfs/xfs_btree_staging.c +++ b/fs/xfs/libxfs/xfs_btree_staging.c @@ -309,7 +309,7 @@ xfs_btree_bload_prep_block( /* Initialize it and send it out. */ xfs_btree_init_block(cur->bc_mp, ifp->if_broot, cur->bc_ops, - level, nr_this_block, cur->bc_ino.ip->i_ino); + level, nr_this_block, I_INO(cur->bc_ino.ip)); *bpp = NULL; *blockp = ifp->if_broot; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index ad801b7bd2dd..9debb95d86fa 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2780,7 +2780,7 @@ xfs_dabuf_map( error = -EFSCORRUPTED; if (xfs_error_level >= XFS_ERRLEVEL_LOW) { xfs_alert(mp, "%s: bno %u inode %llu", - __func__, bno, dp->i_ino); + __func__, bno, I_INO(dp)); for (i = 0; i < nirecs; i++) { xfs_alert(mp, diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 495620cc001f..0c0402a29b6b 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -244,7 +244,7 @@ xfs_dir_init( int error; ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); - error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino); + error = xfs_dir_ino_validate(tp->t_mountp, I_INO(pdp)); if (error) return error; @@ -255,8 +255,8 @@ xfs_dir_init( args->geo = dp->i_mount->m_dir_geo; args->dp = dp; args->trans = tp; - args->owner = dp->i_ino; - error = xfs_dir2_sf_create(args, pdp->i_ino); + args->owner = I_INO(dp); + error = xfs_dir2_sf_create(args, I_INO(pdp)); kfree(args); return error; } @@ -356,7 +356,7 @@ xfs_dir_createname( args->whichfork = XFS_DATA_FORK; args->trans = tp; args->op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; - args->owner = dp->i_ino; + args->owner = I_INO(dp); rval = xfs_dir_createname_args(args); kfree(args); @@ -447,7 +447,7 @@ xfs_dir_lookup( args->whichfork = XFS_DATA_FORK; args->trans = tp; args->op_flags = XFS_DA_OP_OKNOENT; - args->owner = dp->i_ino; + args->owner = I_INO(dp); if (ci_name) args->op_flags |= XFS_DA_OP_CILOOKUP; @@ -516,7 +516,7 @@ xfs_dir_removename( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->owner = dp->i_ino; + args->owner = I_INO(dp); rval = xfs_dir_removename_args(args); kfree(args); return rval; @@ -576,7 +576,7 @@ xfs_dir_replace( args->total = total; args->whichfork = XFS_DATA_FORK; args->trans = tp; - args->owner = dp->i_ino; + args->owner = I_INO(dp); rval = xfs_dir_replace_args(args); kfree(args); return rval; @@ -855,7 +855,7 @@ xfs_dir_create_child( xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); xfs_assert_ilocked(dp, XFS_ILOCK_EXCL); - error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_createname(tp, dp, name, I_INO(ip), resblks); if (error) { ASSERT(error != -ENOSPC); return error; @@ -919,14 +919,14 @@ xfs_dir_add_child( if (VFS_I(ip)->i_nlink == 0) { struct xfs_perag *pag; - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); error = xfs_iunlink_remove(tp, pag, ip); xfs_perag_put(pag); if (error) return error; } - error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_createname(tp, dp, name, I_INO(ip), resblks); if (error) return error; @@ -995,7 +995,7 @@ xfs_dir_remove_child( * get freed before the child directory is closed. If the fs * gets shrunk, this can lead to dirent inode validation errors. */ - if (dp->i_ino != tp->t_mountp->m_sb.sb_rootino) { + if (I_INO(dp) != tp->t_mountp->m_sb.sb_rootino) { error = xfs_dir_replace(tp, ip, &xfs_name_dotdot, tp->t_mountp->m_sb.sb_rootino, 0); if (error) @@ -1016,7 +1016,7 @@ xfs_dir_remove_child( if (error) return error; - error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); + error = xfs_dir_removename(tp, dp, name, I_INO(ip), resblks); if (error) { ASSERT(error != -ENOENT); return error; @@ -1059,12 +1059,12 @@ xfs_dir_exchange_children( int error; /* Swap inode number for dirent in first parent */ - error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres); + error = xfs_dir_replace(tp, dp1, name1, I_INO(ip2), spaceres); if (error) return error; /* Swap inode number for dirent in second parent */ - error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres); + error = xfs_dir_replace(tp, dp2, name2, I_INO(ip1), spaceres); if (error) return error; @@ -1078,7 +1078,7 @@ xfs_dir_exchange_children( if (S_ISDIR(VFS_I(ip2)->i_mode)) { error = xfs_dir_replace(tp, ip2, &xfs_name_dotdot, - dp1->i_ino, spaceres); + I_INO(dp1), spaceres); if (error) return error; @@ -1102,7 +1102,7 @@ xfs_dir_exchange_children( if (S_ISDIR(VFS_I(ip1)->i_mode)) { error = xfs_dir_replace(tp, ip1, &xfs_name_dotdot, - dp2->i_ino, spaceres); + I_INO(dp2), spaceres); if (error) return error; @@ -1246,7 +1246,7 @@ xfs_dir_rename_children( ASSERT(VFS_I(du_wip->ip)->i_nlink == 0); - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, du_wip->ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(du_wip->ip)); error = xfs_iunlink_remove(tp, pag, du_wip->ip); xfs_perag_put(pag); if (error) @@ -1265,7 +1265,7 @@ xfs_dir_rename_children( * to account for the ".." reference from the new entry. */ error = xfs_dir_createname(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + I_INO(src_ip), spaceres); if (error) return error; @@ -1286,7 +1286,7 @@ xfs_dir_rename_children( * name at the destination directory, remove it first. */ error = xfs_dir_replace(tp, target_dp, target_name, - src_ip->i_ino, spaceres); + I_INO(src_ip), spaceres); if (error) return error; @@ -1320,7 +1320,7 @@ xfs_dir_rename_children( * directory. */ error = xfs_dir_replace(tp, src_ip, &xfs_name_dotdot, - target_dp->i_ino, spaceres); + I_INO(target_dp), spaceres); ASSERT(error != -EEXIST); if (error) return error; @@ -1358,10 +1358,10 @@ xfs_dir_rename_children( * altogether. */ if (du_wip->ip) - error = xfs_dir_replace(tp, src_dp, src_name, du_wip->ip->i_ino, + error = xfs_dir_replace(tp, src_dp, src_name, I_INO(du_wip->ip), spaceres); else - error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, + error = xfs_dir_removename(tp, src_dp, src_name, I_INO(src_ip), spaceres); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index ed0b5287a44f..19cb536e53ef 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -1739,7 +1739,7 @@ xfs_dir2_node_add_datablk( fbno)) { xfs_alert(mp, "%s: dir ino %llu needed freesp block %lld for data block %lld, got %lld", - __func__, (unsigned long long)dp->i_ino, + __func__, (unsigned long long)I_INO(dp), (long long)xfs_dir2_db_to_fdb(args->geo, *dbno), (long long)*dbno, (long long)fbno); if (fblk) { diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 1a67cdd6a707..0567cf8b9c1b 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -301,7 +301,7 @@ xfs_dir2_block_to_sf( * Skip . */ if (dep->namelen == 1 && dep->name[0] == '.') - ASSERT(be64_to_cpu(dep->inumber) == dp->i_ino); + ASSERT(be64_to_cpu(dep->inumber) == I_INO(dp)); /* * Skip .., but make sure the inode number is right. */ @@ -863,7 +863,7 @@ xfs_dir2_sf_lookup( * Special case for . */ if (args->namelen == 1 && args->name[0] == '.') { - args->inumber = dp->i_ino; + args->inumber = I_INO(dp); args->cmpresult = XFS_CMP_EXACT; args->filetype = XFS_DIR3_FT_DIR; return -EEXIST; diff --git a/fs/xfs/libxfs/xfs_exchmaps.c b/fs/xfs/libxfs/xfs_exchmaps.c index 5d28f4eac527..dcd0bd0b13b4 100644 --- a/fs/xfs/libxfs/xfs_exchmaps.c +++ b/fs/xfs/libxfs/xfs_exchmaps.c @@ -429,7 +429,7 @@ xfs_exchmaps_attr_to_sf( .geo = tp->t_mountp->m_attr_geo, .whichfork = XFS_ATTR_FORK, .trans = tp, - .owner = xmi->xmi_ip2->i_ino, + .owner = I_INO(xmi->xmi_ip2), }; struct xfs_buf *bp; int forkoff; @@ -438,7 +438,7 @@ xfs_exchmaps_attr_to_sf( if (!xfs_attr_is_leaf(xmi->xmi_ip2)) return 0; - error = xfs_attr3_leaf_read(tp, xmi->xmi_ip2, xmi->xmi_ip2->i_ino, 0, + error = xfs_attr3_leaf_read(tp, xmi->xmi_ip2, I_INO(xmi->xmi_ip2), 0, &bp); if (error) return error; @@ -461,7 +461,7 @@ xfs_exchmaps_dir_to_sf( .geo = tp->t_mountp->m_dir_geo, .whichfork = XFS_DATA_FORK, .trans = tp, - .owner = xmi->xmi_ip2->i_ino, + .owner = I_INO(xmi->xmi_ip2), }; struct xfs_dir2_sf_hdr sfh; struct xfs_buf *bp; @@ -471,7 +471,7 @@ xfs_exchmaps_dir_to_sf( if (xfs_dir2_format(&args, &error) != XFS_DIR2_FMT_BLOCK) return error; - error = xfs_dir3_block_read(tp, xmi->xmi_ip2, xmi->xmi_ip2->i_ino, &bp); + error = xfs_dir3_block_read(tp, xmi->xmi_ip2, I_INO(xmi->xmi_ip2), &bp); if (error) return error; @@ -711,7 +711,7 @@ xfs_exchmaps_estimate_overhead( return -ENOSPC; /* Can't actually reserve more than UINT_MAX blocks. */ - if (req->resblks > UINT_MAX) + if (resblks > UINT_MAX) return -ENOSPC; req->resblks = resblks; diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 779dac59b1f3..dd0ed046fbe9 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -1276,8 +1276,12 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) #define XFS_INO_TO_AGNO(mp,i) \ ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) +#define XFS_INODE_TO_AGNO(ip) \ + XFS_INO_TO_AGNO((ip)->i_mount, I_INO(ip)) #define XFS_INO_TO_AGINO(mp,i) \ ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) +#define XFS_INODE_TO_AGINO(ip) \ + XFS_INO_TO_AGINO((ip)->i_mount, I_INO(ip)) #define XFS_INO_TO_AGBNO(mp,i) \ (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) @@ -1285,6 +1289,8 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip) ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) #define XFS_INO_TO_FSB(mp,i) \ XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) +#define XFS_INODE_TO_FSB(ip) \ + XFS_INO_TO_FSB((ip)->i_mount, I_INO(ip)) #define XFS_AGINO_TO_INO(mp,a,i) \ (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index dcef06ec0a02..ffcdd1f691fd 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -1075,7 +1075,7 @@ xfs_dialloc_check_ino( if (error) return -EAGAIN; - error = xfs_imap_to_bp(pag_mount(pag), tp, &imap, &bp); + error = xfs_read_icluster(pag, tp, imap.im_agbno, &bp); if (error) return -EAGAIN; @@ -1870,7 +1870,7 @@ xfs_dialloc_pick_ag( if (S_ISDIR(mode)) return (atomic_inc_return(&mp->m_agirotor) - 1) % mp->m_maxagi; - start_agno = XFS_INO_TO_AGNO(mp, dp->i_ino); + start_agno = XFS_INODE_TO_AGNO(dp); if (start_agno >= mp->m_maxagi) start_agno = 0; @@ -1895,7 +1895,7 @@ xfs_dialloc( struct xfs_perag *pag; struct xfs_ino_geometry *igeo = M_IGEO(mp); xfs_ino_t ino = NULLFSINO; - xfs_ino_t parent = args->pip ? args->pip->i_ino : 0; + xfs_ino_t parent = args->pip ? I_INO(args->pip) : 0; xfs_agnumber_t agno; xfs_agnumber_t start_agno; umode_t mode = args->mode & S_IFMT; @@ -2511,43 +2511,37 @@ xfs_imap( * inodes in stale state on disk. Hence we have to do a btree lookup * in all cases where an untrusted inode number is passed. */ - if (flags & XFS_IGET_UNTRUSTED) { - error = xfs_imap_lookup(pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); - if (error) - return error; - goto out_map; + if (!(flags & XFS_IGET_UNTRUSTED)) { + /* + * If the inode cluster size is the same or smaller than the + * blocksize, get to the buffer by simple arithmetics. + */ + if (M_IGEO(mp)->blocks_per_cluster == 1) { + cluster_agbno = agbno; + offset = XFS_INO_TO_OFFSET(mp, ino); + ASSERT(offset < mp->m_sb.sb_inopblock); + goto out; + } + + /* + * If the inode chunks are aligned, use simple maths to find the + * location. + */ + if (M_IGEO(mp)->inoalign_mask) { + offset_agbno = agbno & M_IGEO(mp)->inoalign_mask; + chunk_agbno = agbno - offset_agbno; + goto out_map; + } + + /* + * Otherwise we have to do a btree lookup to find the location. + */ } - /* - * If the inode cluster size is the same as the blocksize or - * smaller we get to the buffer by simple arithmetics. - */ - if (M_IGEO(mp)->blocks_per_cluster == 1) { - offset = XFS_INO_TO_OFFSET(mp, ino); - ASSERT(offset < mp->m_sb.sb_inopblock); - - imap->im_blkno = xfs_agbno_to_daddr(pag, agbno); - imap->im_len = XFS_FSB_TO_BB(mp, 1); - imap->im_boffset = (unsigned short)(offset << - mp->m_sb.sb_inodelog); - return 0; - } - - /* - * If the inode chunks are aligned then use simple maths to - * find the location. Otherwise we have to do a btree - * lookup to find the location. - */ - if (M_IGEO(mp)->inoalign_mask) { - offset_agbno = agbno & M_IGEO(mp)->inoalign_mask; - chunk_agbno = agbno - offset_agbno; - } else { - error = xfs_imap_lookup(pag, tp, agino, agbno, - &chunk_agbno, &offset_agbno, flags); - if (error) - return error; - } + error = xfs_imap_lookup(pag, tp, agino, agbno, &chunk_agbno, + &offset_agbno, flags); + if (error) + return error; out_map: ASSERT(agbno >= chunk_agbno); @@ -2556,24 +2550,14 @@ xfs_imap( M_IGEO(mp)->blocks_per_cluster); offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) + XFS_INO_TO_OFFSET(mp, ino); - - imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno); - imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster); +out: + imap->im_agbno = cluster_agbno; imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); - - /* - * If the inode number maps to a block outside the bounds - * of the file system then return NULL rather than calling - * read_buf and panicing when we get an error from the - * driver. - */ - if ((imap->im_blkno + imap->im_len) > - XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) { - xfs_alert(mp, - "%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)", - __func__, (unsigned long long) imap->im_blkno, - (unsigned long long) imap->im_len, - XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)); + if (imap->im_agbno + M_IGEO(mp)->blocks_per_cluster > + pag_group(pag)->xg_block_count) { + xfs_alert(mp, "inode cluster out of range: %u/%u > %u", + imap->im_agbno, M_IGEO(mp)->blocks_per_cluster, + pag_group(pag)->xg_block_count); return -EINVAL; } return 0; diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 3794e5412eba..336ef843f2fe 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -123,24 +123,24 @@ const struct xfs_buf_ops xfs_inode_buf_ra_ops = { /* - * This routine is called to map an inode to the buffer containing the on-disk - * version of the inode. It returns a pointer to the buffer containing the - * on-disk inode in the bpp parameter. + * Read the inode cluster at @bno and return it in @bpp. */ int -xfs_imap_to_bp( - struct xfs_mount *mp, +xfs_read_icluster( + struct xfs_perag *pag, struct xfs_trans *tp, - struct xfs_imap *imap, + xfs_agblock_t agbno, struct xfs_buf **bpp) { + struct xfs_mount *mp = pag_mount(pag); int error; - error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, - imap->im_len, 0, bpp, &xfs_inode_buf_ops); + error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, + xfs_agbno_to_daddr(pag, agbno), + XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), + 0, bpp, &xfs_inode_buf_ops); if (xfs_metadata_is_sick(error)) - xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, imap->im_blkno), - XFS_SICK_AG_INODES); + xfs_agno_mark_sick(mp, pag_agno(pag), XFS_SICK_AG_INODES); return error; } @@ -185,7 +185,7 @@ xfs_inode_from_disk( ASSERT(ip->i_cowfp == NULL); - fa = xfs_dinode_verify(ip->i_mount, ip->i_ino, from); + fa = xfs_dinode_verify(ip->i_mount, I_INO(ip), from); if (fa) { xfs_inode_verifier_error(ip, -EFSCORRUPTED, "dinode", from, sizeof(*from), fa); @@ -358,7 +358,7 @@ xfs_inode_to_disk( to->di_flags2 = cpu_to_be64(ip->i_diflags2); /* also covers the di_used_blocks union arm: */ to->di_cowextsize = cpu_to_be32(ip->i_cowextsize); - to->di_ino = cpu_to_be64(ip->i_ino); + to->di_ino = cpu_to_be64(I_INO(ip)); to->di_lsn = cpu_to_be64(lsn); memset(to->di_pad2, 0, sizeof(to->di_pad2)); uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid); diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h index 8d43d2641c73..f3624532b023 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.h +++ b/fs/xfs/libxfs/xfs_inode_buf.h @@ -11,16 +11,15 @@ struct xfs_dinode; /* * Inode location information. Stored in the inode and passed to - * xfs_imap_to_bp() to get a buffer and dinode for a given inode. + * xfs_read_icluster() to get a buffer and dinode for a given inode. */ struct xfs_imap { - xfs_daddr_t im_blkno; /* starting BB of inode chunk */ - unsigned short im_len; /* length in BBs of inode chunk */ - unsigned short im_boffset; /* inode offset in block in bytes */ -}; + xfs_agblock_t im_agbno; /* starting agbno of inode cluster */ + unsigned short im_boffset; /* offset in inode cluster in bytes */ +} __packed; -int xfs_imap_to_bp(struct xfs_mount *mp, struct xfs_trans *tp, - struct xfs_imap *imap, struct xfs_buf **bpp); +int xfs_read_icluster(struct xfs_perag *pag, struct xfs_trans *tp, + xfs_agblock_t agbno, struct xfs_buf **bpp); void xfs_dinode_calc_crc(struct xfs_mount *mp, struct xfs_dinode *dip); void xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to, xfs_lsn_t lsn); diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index d14a7f2f4c03..606a36526ce2 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -87,7 +87,7 @@ xfs_iformat_local( if (unlikely(size > XFS_DFORK_SIZE(dip, ip->i_mount, whichfork))) { xfs_warn(ip->i_mount, "corrupt inode %llu (bad size %d for local fork, size = %zd).", - (unsigned long long) ip->i_ino, size, + (unsigned long long)I_INO(ip), size, XFS_DFORK_SIZE(dip, ip->i_mount, whichfork)); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "xfs_iformat_local", dip, sizeof(*dip), @@ -126,7 +126,7 @@ xfs_iformat_extents( */ if (unlikely(size < 0 || size > XFS_DFORK_SIZE(dip, mp, whichfork))) { xfs_warn(ip->i_mount, "corrupt inode %llu ((a)extents = %llu).", - ip->i_ino, nex); + I_INO(ip), nex); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "xfs_iformat_extents(1)", dip, sizeof(*dip), __this_address); @@ -205,7 +205,7 @@ xfs_iformat_btree( ifp->if_nextents > ip->i_nblocks) || level == 0 || level > XFS_BM_MAXLEVELS(mp, whichfork)) { xfs_warn(mp, "corrupt inode %llu (btree).", - (unsigned long long) ip->i_ino); + (unsigned long long)I_INO(ip)); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "xfs_iformat_btree", dfp, size, __this_address); diff --git a/fs/xfs/libxfs/xfs_inode_util.c b/fs/xfs/libxfs/xfs_inode_util.c index 82be54b6f8d3..258ac3d0d486 100644 --- a/fs/xfs/libxfs/xfs_inode_util.c +++ b/fs/xfs/libxfs/xfs_inode_util.c @@ -464,10 +464,9 @@ xfs_iunlink_insert_inode( struct xfs_buf *agibp, struct xfs_inode *ip) { - struct xfs_mount *mp = tp->t_mountp; struct xfs_agi *agi = agibp->b_addr; xfs_agino_t next_agino; - xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); + xfs_agino_t agino = XFS_INODE_TO_AGINO(ip); short bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; int error; @@ -531,7 +530,7 @@ xfs_iunlink( ASSERT(VFS_I(ip)->i_mode != 0); trace_xfs_iunlink(ip); - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); /* Get the agi buffer first. It ensures lock ordering on the list. */ error = xfs_read_agi(pag, tp, 0, &agibp); @@ -553,7 +552,7 @@ xfs_iunlink_remove_inode( { struct xfs_mount *mp = tp->t_mountp; struct xfs_agi *agi = agibp->b_addr; - xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); + xfs_agino_t agino = XFS_INODE_TO_AGINO(ip); xfs_agino_t head_agino; short bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; int error; @@ -655,7 +654,7 @@ xfs_droplink( if (inode->i_nlink == 0) { xfs_info_ratelimited(tp->t_mountp, "Inode 0x%llx link count dropped below zero. Pinning link count.", - ip->i_ino); + I_INO(ip)); set_nlink(inode, XFS_NLINK_PINNED); } if (inode->i_nlink != XFS_NLINK_PINNED) @@ -684,7 +683,7 @@ xfs_bumplink( if (inode->i_nlink == XFS_NLINK_PINNED - 1) xfs_info_ratelimited(tp->t_mountp, "Inode 0x%llx link count exceeded maximum. Pinning link count.", - ip->i_ino); + I_INO(ip)); if (inode->i_nlink != XFS_NLINK_PINNED) inc_nlink(inode); @@ -708,7 +707,7 @@ xfs_inode_uninit( * makes the AGI lock -> unlinked list modification order the same as * used in O_TMPFILE creation. */ - error = xfs_difree(tp, pag, ip->i_ino, xic); + error = xfs_difree(tp, pag, I_INO(ip), xic); if (error) return error; diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index 3f5a24dda907..a4e1b3eb425c 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -52,6 +52,19 @@ typedef uint32_t xlog_tid_t; #define CYCLE_LSN(lsn) ((uint)((lsn)>>32)) #define BLOCK_LSN(lsn) ((uint)(lsn)) +/* + * By comparing each component, we don't have to worry about extra endian issues + * in treating two 32 bit numbers as one 64 bit number + */ +static inline xfs_lsn_t XFS_LSN_CMP(xfs_lsn_t lsn1, xfs_lsn_t lsn2) +{ + if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2)) + return CYCLE_LSN(lsn1) < CYCLE_LSN(lsn2) ? -999 : 999; + if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2)) + return BLOCK_LSN(lsn1) < BLOCK_LSN(lsn2) ? -999 : 999; + return 0; +} + /* this is used in a spot where we might otherwise double-endian-flip */ #define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0]) diff --git a/fs/xfs/libxfs/xfs_metadir.c b/fs/xfs/libxfs/xfs_metadir.c index 3e5c61188927..74c4596ee4cf 100644 --- a/fs/xfs/libxfs/xfs_metadir.c +++ b/fs/xfs/libxfs/xfs_metadir.c @@ -95,7 +95,7 @@ xfs_metadir_lookup( .hashval = xfs_dir2_hashname(mp, xname), .whichfork = XFS_DATA_FORK, .op_flags = XFS_DA_OP_OKNOENT, - .owner = dp->i_ino, + .owner = I_INO(dp), }; int error; diff --git a/fs/xfs/libxfs/xfs_parent.c b/fs/xfs/libxfs/xfs_parent.c index 3509cc4b2175..8d111c9b6527 100644 --- a/fs/xfs/libxfs/xfs_parent.c +++ b/fs/xfs/libxfs/xfs_parent.c @@ -23,7 +23,6 @@ #include "xfs_attr_sf.h" #include "xfs_bmap.h" #include "xfs_defer.h" -#include "xfs_log.h" #include "xfs_xattr.h" #include "xfs_parent.h" #include "xfs_trans_space.h" @@ -202,7 +201,7 @@ xfs_parent_addname( xfs_inode_to_parent_rec(&ppargs->rec, dp); xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->rec, child, - child->i_ino, parent_name); + I_INO(child), parent_name); return xfs_attr_setname(&ppargs->args, 0); } @@ -224,7 +223,7 @@ xfs_parent_removename( xfs_inode_to_parent_rec(&ppargs->rec, dp); xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->rec, child, - child->i_ino, parent_name); + I_INO(child), parent_name); return xfs_attr_removename(&ppargs->args); } @@ -248,7 +247,7 @@ xfs_parent_replacename( xfs_inode_to_parent_rec(&ppargs->rec, old_dp); xfs_parent_da_args_init(&ppargs->args, tp, &ppargs->rec, child, - child->i_ino, old_name); + I_INO(child), old_name); xfs_inode_to_parent_rec(&ppargs->new_rec, new_dp); @@ -312,7 +311,7 @@ xfs_parent_lookup( struct xfs_da_args *scratch) { memset(scratch, 0, sizeof(struct xfs_da_args)); - xfs_parent_da_args_init(scratch, tp, pptr, ip, ip->i_ino, parent_name); + xfs_parent_da_args_init(scratch, tp, pptr, ip, I_INO(ip), parent_name); return xfs_attr_get_ilocked(scratch); } diff --git a/fs/xfs/libxfs/xfs_parent.h b/fs/xfs/libxfs/xfs_parent.h index b8036527cdc7..8eb4de9c5f1a 100644 --- a/fs/xfs/libxfs/xfs_parent.h +++ b/fs/xfs/libxfs/xfs_parent.h @@ -34,7 +34,7 @@ xfs_inode_to_parent_rec( struct xfs_parent_rec *rec, const struct xfs_inode *dp) { - xfs_parent_rec_init(rec, dp->i_ino, VFS_IC(dp)->i_generation); + xfs_parent_rec_init(rec, I_INO(dp), VFS_IC(dp)->i_generation); } extern struct kmem_cache *xfs_parent_args_cache; diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c index e78133c908ca..34d218de21a9 100644 --- a/fs/xfs/libxfs/xfs_rmap.c +++ b/fs/xfs/libxfs/xfs_rmap.c @@ -2780,7 +2780,7 @@ xfs_rmap_map_extent( if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) type = XFS_RMAP_MAP_SHARED; - __xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV); + __xfs_rmap_add(tp, type, I_INO(ip), isrt, whichfork, PREV); } /* Unmap an extent out of a file. */ @@ -2800,7 +2800,7 @@ xfs_rmap_unmap_extent( if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) type = XFS_RMAP_UNMAP_SHARED; - __xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV); + __xfs_rmap_add(tp, type, I_INO(ip), isrt, whichfork, PREV); } /* @@ -2826,7 +2826,7 @@ xfs_rmap_convert_extent( if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) type = XFS_RMAP_CONVERT_SHARED; - __xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV); + __xfs_rmap_add(tp, type, I_INO(ip), isrt, whichfork, PREV); } /* Schedule the creation of an rmap for non-file data. */ diff --git a/fs/xfs/libxfs/xfs_rmap.h b/fs/xfs/libxfs/xfs_rmap.h index 5f39f6e53cd1..4afa33575ce2 100644 --- a/fs/xfs/libxfs/xfs_rmap.h +++ b/fs/xfs/libxfs/xfs_rmap.h @@ -21,6 +21,8 @@ xfs_rmap_ino_bmbt_owner( if (whichfork == XFS_ATTR_FORK) oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; } +#define xfs_rmap_inode_bmbt_owner(oi, ip, whichfork) \ + xfs_rmap_ino_bmbt_owner(oi, I_INO(ip), whichfork) static inline void xfs_rmap_ino_owner( @@ -35,6 +37,8 @@ xfs_rmap_ino_owner( if (whichfork == XFS_ATTR_FORK) oi->oi_flags |= XFS_OWNER_INFO_ATTR_FORK; } +#define xfs_rmap_inode_owner(oi, ip, whichfork, offset) \ + xfs_rmap_ino_owner(oi, I_INO(ip), whichfork, offset) static inline bool xfs_rmap_should_skip_owner_update( diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index bc4c0a99f4dd..e62786e90f7b 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c @@ -214,7 +214,7 @@ xfs_rtbuf_get( if (xfs_has_rtgroups(mp)) { struct xfs_rtbuf_blkinfo *hdr = bp->b_addr; - if (hdr->rt_owner != cpu_to_be64(ip->i_ino)) { + if (hdr->rt_owner != cpu_to_be64(I_INO(ip))) { xfs_buf_mark_corrupt(bp); xfs_trans_brelse(args->tp, bp); xfs_rtginode_mark_sick(args->rtg, type); @@ -1409,7 +1409,7 @@ xfs_rtfile_initialize_block( hdr->rt_magic = cpu_to_be32(XFS_RTBITMAP_MAGIC); else hdr->rt_magic = cpu_to_be32(XFS_RTSUMMARY_MAGIC); - hdr->rt_owner = cpu_to_be64(ip->i_ino); + hdr->rt_owner = cpu_to_be64(I_INO(ip)); hdr->rt_blkno = cpu_to_be64(XFS_FSB_TO_DADDR(mp, fsbno)); hdr->rt_lsn = 0; uuid_copy(&hdr->rt_uuid, &mp->m_sb.sb_meta_uuid); diff --git a/fs/xfs/libxfs/xfs_rtrefcount_btree.c b/fs/xfs/libxfs/xfs_rtrefcount_btree.c index c1518267eb17..f27b80a199ba 100644 --- a/fs/xfs/libxfs/xfs_rtrefcount_btree.c +++ b/fs/xfs/libxfs/xfs_rtrefcount_btree.c @@ -602,7 +602,7 @@ xfs_rtrefcountbt_from_disk( rblocklen = xfs_rtrefcount_broot_space(mp, dblock); xfs_btree_init_block(mp, rblock, &xfs_rtrefcountbt_ops, 0, 0, - ip->i_ino); + I_INO(ip)); rblock->bb_level = dblock->bb_level; rblock->bb_numrecs = dblock->bb_numrecs; @@ -751,7 +751,7 @@ xfs_rtrefcountbt_create( xfs_rtrefcount_broot_space_calc(mp, 0, 0)); if (broot) xfs_btree_init_block(mp, broot, &xfs_rtrefcountbt_ops, 0, 0, - ip->i_ino); + I_INO(ip)); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE | XFS_ILOG_DBROOT); return 0; } diff --git a/fs/xfs/libxfs/xfs_rtrmap_btree.c b/fs/xfs/libxfs/xfs_rtrmap_btree.c index 00557b7ef298..c264bc5651c0 100644 --- a/fs/xfs/libxfs/xfs_rtrmap_btree.c +++ b/fs/xfs/libxfs/xfs_rtrmap_btree.c @@ -839,7 +839,7 @@ xfs_rtrmapbt_from_disk( unsigned int numrecs; unsigned int maxrecs; - xfs_btree_init_block(mp, rblock, &xfs_rtrmapbt_ops, 0, 0, ip->i_ino); + xfs_btree_init_block(mp, rblock, &xfs_rtrmapbt_ops, 0, 0, I_INO(ip)); rblock->bb_level = dblock->bb_level; rblock->bb_numrecs = dblock->bb_numrecs; @@ -981,7 +981,7 @@ xfs_rtrmapbt_create( broot = xfs_broot_realloc(ifp, xfs_rtrmap_broot_space_calc(mp, 0, 0)); if (broot) xfs_btree_init_block(mp, broot, &xfs_rtrmapbt_ops, 0, 0, - ip->i_ino); + I_INO(ip)); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE | XFS_ILOG_DBROOT); return 0; diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c index f9a5966d8048..b0dc3888bf1b 100644 --- a/fs/xfs/libxfs/xfs_symlink_remote.c +++ b/fs/xfs/libxfs/xfs_symlink_remote.c @@ -196,7 +196,7 @@ xfs_symlink_local_to_remote( bp->b_ops = &xfs_symlink_buf_ops; buf = bp->b_addr; - buf += xfs_symlink_hdr_set(mp, ip->i_ino, 0, ifp->if_bytes, bp); + buf += xfs_symlink_hdr_set(mp, I_INO(ip), 0, ifp->if_bytes, bp); memcpy(buf, ifp->if_data, ifp->if_bytes); xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsymlink_hdr) + ifp->if_bytes - 1); @@ -277,13 +277,13 @@ xfs_symlink_remote_read( cur_chunk = bp->b_addr; if (xfs_has_crc(mp)) { - if (!xfs_symlink_hdr_ok(ip->i_ino, offset, + if (!xfs_symlink_hdr_ok(I_INO(ip), offset, byte_cnt, bp)) { xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK); error = -EFSCORRUPTED; xfs_alert(mp, "symlink header does not match required off/len/owner (0x%x/0x%x,0x%llx)", - offset, byte_cnt, ip->i_ino); + offset, byte_cnt, I_INO(ip)); xfs_buf_relse(bp); goto out; diff --git a/fs/xfs/scrub/agheader_repair.c b/fs/xfs/scrub/agheader_repair.c index ae9ed5f280d0..7114c9a44182 100644 --- a/fs/xfs/scrub/agheader_repair.c +++ b/fs/xfs/scrub/agheader_repair.c @@ -1116,9 +1116,7 @@ xrep_iunlink_igrab( struct xfs_perag *pag, struct xfs_inode *ip) { - struct xfs_mount *mp = pag_mount(pag); - - if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag_agno(pag)) + if (XFS_INODE_TO_AGNO(ip) != pag_agno(pag)) return false; if (!xfs_inode_on_unlinked_list(ip)) @@ -1136,18 +1134,14 @@ xrep_iunlink_visit( struct xrep_agi *ragi, unsigned int batch_idx) { - struct xfs_mount *mp = ragi->sc->mp; struct xfs_inode *ip = ragi->lookup_batch[batch_idx]; - xfs_agino_t agino; - unsigned int bucket; + xfs_agino_t agino = XFS_INODE_TO_AGINO(ip); + unsigned int bucket = agino % XFS_AGI_UNLINKED_BUCKETS; int error; - ASSERT(XFS_INO_TO_AGNO(mp, ip->i_ino) == pag_agno(ragi->sc->sa.pag)); + ASSERT(XFS_INODE_TO_AGNO(ip) == pag_agno(ragi->sc->sa.pag)); ASSERT(xfs_inode_on_unlinked_list(ip)); - agino = XFS_INO_TO_AGINO(mp, ip->i_ino); - bucket = agino % XFS_AGI_UNLINKED_BUCKETS; - trace_xrep_iunlink_visit(ragi->sc->sa.pag, bucket, ragi->iunlink_heads[bucket], ip); @@ -1213,10 +1207,10 @@ xrep_iunlink_mark_incore( * us to see this inode, so another lookup from the * same index will not find it again. */ - if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag_agno(pag)) + if (XFS_INODE_TO_AGNO(ip) != pag_agno(pag)) continue; - first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1); - if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino)) + first_index = XFS_INO_TO_AGINO(mp, I_INO(ip) + 1); + if (first_index < XFS_INODE_TO_AGINO(ip)) done = true; } diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c index 390ac2e11ee0..d5226939c810 100644 --- a/fs/xfs/scrub/attr.c +++ b/fs/xfs/scrub/attr.c @@ -182,7 +182,7 @@ xchk_xattr_actor( .namelen = namelen, .trans = sc->tp, .valuelen = valuelen, - .owner = ip->i_ino, + .owner = I_INO(ip), }; struct xchk_xattr_buf *ab; int error = 0; @@ -199,7 +199,7 @@ xchk_xattr_actor( if (attr_flags & XFS_ATTR_INCOMPLETE) { /* Incomplete attr key, just mark the inode for preening. */ - xchk_ino_set_preen(sc, ip->i_ino); + xchk_ino_set_preen(sc, I_INO(ip)); return 0; } diff --git a/fs/xfs/scrub/attr_repair.c b/fs/xfs/scrub/attr_repair.c index 7d00a1ce0bac..be627ab655ad 100644 --- a/fs/xfs/scrub/attr_repair.c +++ b/fs/xfs/scrub/attr_repair.c @@ -329,7 +329,7 @@ xrep_xattr_salvage_remote_attr( .dp = rx->sc->ip, .index = ent_idx, .geo = rx->sc->mp->m_attr_geo, - .owner = rx->sc->ip->i_ino, + .owner = I_INO(rx->sc->ip), .attr_filter = ent->flags & XFS_ATTR_NSP_ONDISK_MASK, .namelen = rentry->namelen, .name = rentry->name, @@ -590,7 +590,7 @@ xrep_xattr_recover_block( * as much as we can from the block. */ if (info->magic == cpu_to_be16(XFS_ATTR3_LEAF_MAGIC) && xrep_buf_verify_struct(bp, &xfs_attr3_leaf_buf_ops) && - xfs_attr3_leaf_header_check(bp, rx->sc->ip->i_ino) == NULL) + xfs_attr3_leaf_header_check(bp, I_INO(rx->sc->ip)) == NULL) error = xrep_xattr_recover_leaf(rx, bp); /* @@ -617,7 +617,7 @@ xrep_xattr_insert_rec( .attr_filter = key->flags, .namelen = key->namelen, .valuelen = key->valuelen, - .owner = rx->sc->ip->i_ino, + .owner = I_INO(rx->sc->ip), .geo = rx->sc->mp->m_attr_geo, .whichfork = XFS_ATTR_FORK, .op_flags = XFS_DA_OP_OKNOENT, @@ -982,7 +982,7 @@ xrep_xattr_fork_remove( xfs_emerg(sc->mp, "inode 0x%llx attr fork still has %llu attr extents, format %d?!", - ip->i_ino, ifp->if_nextents, ifp->if_format); + I_INO(ip), ifp->if_nextents, ifp->if_format); for_each_xfs_iext(ifp, &icur, &irec) { xfs_err(sc->mp, "[%u]: startoff %llu startblock %llu blockcount %llu state %u", @@ -1116,7 +1116,7 @@ xrep_xattr_replay_pptr_update( trace_xrep_xattr_replay_parentadd(sc->tempip, xname, &pptr->pptr_rec); - error = xfs_parent_set(sc->tempip, sc->ip->i_ino, xname, + error = xfs_parent_set(sc->tempip, I_INO(sc->ip), xname, &pptr->pptr_rec, &rx->pptr_args); ASSERT(error != -EEXIST); return error; @@ -1125,7 +1125,7 @@ xrep_xattr_replay_pptr_update( trace_xrep_xattr_replay_parentremove(sc->tempip, xname, &pptr->pptr_rec); - error = xfs_parent_unset(sc->tempip, sc->ip->i_ino, xname, + error = xfs_parent_unset(sc->tempip, I_INO(sc->ip), xname, &pptr->pptr_rec, &rx->pptr_args); ASSERT(error != -ENOATTR); return error; @@ -1256,7 +1256,7 @@ xrep_xattr_live_dirent_update( * repairing, so stash the update for replay against the temporary * file. */ - if (p->ip->i_ino != sc->ip->i_ino) + if (I_INO(p->ip) != I_INO(sc->ip)) return NOTIFY_DONE; mutex_lock(&rx->lock); @@ -1295,7 +1295,7 @@ xrep_xattr_swap_prep( .whichfork = XFS_ATTR_FORK, .trans = sc->tp, .total = 1, - .owner = sc->ip->i_ino, + .owner = I_INO(sc->ip), }; error = xfs_attr_shortform_to_leaf(&args); diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index d40534bf9ef9..70028da1aacc 100644 --- a/fs/xfs/scrub/bmap.c +++ b/fs/xfs/scrub/bmap.c @@ -205,7 +205,7 @@ xchk_bmap_xref_rmap( { struct xfs_rmap_irec rmap; unsigned long long rmap_end; - uint64_t owner = info->sc->ip->i_ino; + uint64_t owner = I_INO(info->sc->ip); if (xchk_skip_xref(info->sc->sm)) return; @@ -352,7 +352,7 @@ xchk_bmap_rt_iextent_xref( case XFS_DATA_FORK: xchk_bmap_xref_rmap(info, irec, rgbno); if (!xfs_is_reflink_inode(info->sc->ip)) { - xfs_rmap_ino_owner(&oinfo, info->sc->ip->i_ino, + xfs_rmap_inode_owner(&oinfo, info->sc->ip, info->whichfork, irec->br_startoff); xchk_xref_is_only_rt_owned_by(info->sc, rgbno, irec->br_blockcount, &oinfo); @@ -407,7 +407,7 @@ xchk_bmap_iextent_xref( case XFS_DATA_FORK: xchk_bmap_xref_rmap(info, irec, agbno); if (!xfs_is_reflink_inode(info->sc->ip)) { - xfs_rmap_ino_owner(&oinfo, info->sc->ip->i_ino, + xfs_rmap_inode_owner(&oinfo, info->sc->ip, info->whichfork, irec->br_startoff); xchk_xref_is_only_owned_by(info->sc, agbno, irec->br_blockcount, &oinfo); @@ -419,7 +419,7 @@ xchk_bmap_iextent_xref( break; case XFS_ATTR_FORK: xchk_bmap_xref_rmap(info, irec, agbno); - xfs_rmap_ino_owner(&oinfo, info->sc->ip->i_ino, + xfs_rmap_inode_owner(&oinfo, info->sc->ip, info->whichfork, irec->br_startoff); xchk_xref_is_only_owned_by(info->sc, agbno, irec->br_blockcount, &oinfo); @@ -543,7 +543,7 @@ xchk_bmapbt_rec( for (i = 0; i < bs->cur->bc_nlevels - 1; i++) { block = xfs_btree_get_block(bs->cur, i, &bp); owner = be64_to_cpu(block->bb_u.l.bb_owner); - if (owner != ip->i_ino) + if (owner != I_INO(ip)) xchk_fblock_set_corrupt(bs->sc, info->whichfork, 0); } @@ -600,7 +600,7 @@ xchk_bmap_btree( /* Check the btree structure. */ cur = xfs_bmbt_init_cursor(mp, sc->tp, ip, whichfork); - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, ip, whichfork); error = xchk_btree(sc, cur, xchk_bmapbt_rec, &oinfo, info); xfs_btree_del_cursor(cur, error); out: @@ -628,7 +628,7 @@ xchk_bmap_check_rmap( bool have_map; /* Is this even the right fork? */ - if (rec->rm_owner != sc->ip->i_ino) + if (rec->rm_owner != I_INO(sc->ip)) return 0; if ((sbcri->whichfork == XFS_ATTR_FORK) ^ !!(rec->rm_flags & XFS_RMAP_ATTR_FORK)) @@ -1003,7 +1003,7 @@ xchk_bmap_iext_iter( */ if (nr > 1 && info->whichfork != XFS_COW_FORK && howmany_64(irec->br_blockcount, XFS_MAX_BMBT_EXTLEN) < nr) - xchk_ino_set_preen(info->sc, info->sc->ip->i_ino); + xchk_ino_set_preen(info->sc, I_INO(info->sc->ip)); return true; } @@ -1040,7 +1040,7 @@ xchk_bmap( case XFS_COW_FORK: /* No CoW forks filesystem doesn't support out of place writes */ if (!xfs_has_reflink(mp) && !xfs_has_zoned(mp)) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } break; @@ -1052,7 +1052,7 @@ xchk_bmap( * attr here. */ if (!xfs_has_attr(mp)) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); break; default: ASSERT(whichfork == XFS_DATA_FORK); @@ -1137,7 +1137,7 @@ xchk_bmap_data( int error; if (xchk_file_looks_zapped(sc, XFS_SICK_INO_BMBTD_ZAPPED)) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } @@ -1165,7 +1165,7 @@ xchk_bmap_attr( * returning immediately. */ if (xchk_file_looks_zapped(sc, XFS_SICK_INO_BMBTA_ZAPPED)) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } diff --git a/fs/xfs/scrub/bmap_repair.c b/fs/xfs/scrub/bmap_repair.c index 822a4af43833..eabffba47776 100644 --- a/fs/xfs/scrub/bmap_repair.c +++ b/fs/xfs/scrub/bmap_repair.c @@ -252,7 +252,7 @@ xrep_bmap_walk_rmap( if (xchk_should_terminate(rb->sc, &error)) return error; - if (rec->rm_owner != rb->sc->ip->i_ino) + if (rec->rm_owner != I_INO(rb->sc->ip)) return 0; error = xrep_bmap_check_fork_rmap(rb, cur, rec); @@ -416,7 +416,7 @@ xrep_bmap_walk_rtrmap( return error; /* Skip extents which are not owned by this inode and fork. */ - if (rec->rm_owner != rb->sc->ip->i_ino) + if (rec->rm_owner != I_INO(rb->sc->ip)) return 0; error = xrep_bmap_check_rtfork_rmap(rb->sc, cur, rec); @@ -760,7 +760,7 @@ xrep_bmap_build_new_fork( * Prepare to construct the new fork by initializing the new btree * structure and creating a fake ifork in the ifakeroot structure. */ - xfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, rb->whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, sc->ip, rb->whichfork); error = xrep_newbt_init_inode(&rb->new_bmapbt, sc, rb->whichfork, &oinfo); if (error) @@ -833,7 +833,7 @@ xrep_bmap_remove_old_tree( struct xfs_owner_info oinfo; /* Free the old bmbt blocks if they're not in use. */ - xfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, rb->whichfork); + xfs_rmap_inode_bmbt_owner(&oinfo, sc->ip, rb->whichfork); return xrep_reap_fsblocks(sc, &rb->old_bmbt_blocks, &oinfo); } diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 3d40cb0b2496..e5233e31abb7 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -320,12 +320,12 @@ xchk_ino_set_corrupt( /* Record a corruption while cross-referencing with an inode. */ void -xchk_ino_xref_set_corrupt( +xchk_ip_xref_set_corrupt( struct xfs_scrub *sc, - xfs_ino_t ino) + struct xfs_inode *ip) { sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT; - trace_xchk_ino_error(sc, ino, __return_address); + trace_xchk_ino_error(sc, I_INO(ip), __return_address); } /* Record corruption in a block indexed by a file fork. */ @@ -1110,7 +1110,7 @@ xchk_install_live_inode( struct xfs_inode *ip) { if (!igrab(VFS_I(ip))) { - xchk_ino_set_corrupt(sc, ip->i_ino); + xchk_ip_set_corrupt(sc, ip); return -EFSCORRUPTED; } @@ -1141,7 +1141,7 @@ xchk_iget_for_scrubbing( ASSERT(sc->tp == NULL); /* We want to scan the inode we already had opened. */ - if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == ip_in->i_ino) + if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == I_INO(ip_in)) return xchk_install_live_inode(sc, ip_in); /* @@ -1439,13 +1439,13 @@ xchk_metadata_inode_forks( /* Metadata inodes don't live on the rt device. */ if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } /* They should never participate in reflink. */ if (xfs_is_reflink_inode(sc->ip)) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } @@ -1462,7 +1462,7 @@ xchk_metadata_inode_forks( &error)) return error; if (shared) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); } /* @@ -1471,7 +1471,7 @@ xchk_metadata_inode_forks( */ if (xfs_inode_hasattr(sc->ip)) { if (!xfs_has_metadir(sc->mp)) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } @@ -1573,7 +1573,7 @@ xchk_inode_is_allocated( * This isn't the inode we want. */ spin_lock(&ip->i_flags_lock); - if (ip->i_ino != ino) + if (I_INO(ip) != ino) goto out_skip; trace_xchk_inode_is_allocated(ip); @@ -1681,7 +1681,7 @@ bool xchk_inode_is_sb_rooted(const struct xfs_inode *ip) { return xchk_inode_is_dirtree_root(ip) || - xfs_is_sb_inum(ip->i_mount, ip->i_ino); + xfs_is_sb_inum(ip->i_mount, I_INO(ip)); } /* What is the root directory inumber for this inode? */ @@ -1691,8 +1691,8 @@ xchk_inode_rootdir_inum(const struct xfs_inode *ip) struct xfs_mount *mp = ip->i_mount; if (xfs_is_metadir_inode(ip)) - return mp->m_metadirip->i_ino; - return mp->m_rootip->i_ino; + return I_INO(mp->m_metadirip); + return I_INO(mp->m_rootip); } static int diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index b494d747c008..9d627fd50687 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -32,6 +32,8 @@ void xchk_set_corrupt(struct xfs_scrub *sc); void xchk_block_set_corrupt(struct xfs_scrub *sc, struct xfs_buf *bp); void xchk_ino_set_corrupt(struct xfs_scrub *sc, xfs_ino_t ino); +#define xchk_ip_set_corrupt(_sc, _ip) \ + xchk_ino_set_corrupt((_sc), I_INO(_ip)) void xchk_fblock_set_corrupt(struct xfs_scrub *sc, int whichfork, xfs_fileoff_t offset); #ifdef CONFIG_XFS_QUOTA @@ -41,8 +43,8 @@ void xchk_qcheck_set_corrupt(struct xfs_scrub *sc, unsigned int dqtype, void xchk_block_xref_set_corrupt(struct xfs_scrub *sc, struct xfs_buf *bp); -void xchk_ino_xref_set_corrupt(struct xfs_scrub *sc, - xfs_ino_t ino); +void xchk_ip_xref_set_corrupt(struct xfs_scrub *sc, + struct xfs_inode *ip); void xchk_fblock_xref_set_corrupt(struct xfs_scrub *sc, int whichfork, xfs_fileoff_t offset); diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c index c25716fc4fee..0075b6d5a1b5 100644 --- a/fs/xfs/scrub/cow_repair.c +++ b/fs/xfs/scrub/cow_repair.c @@ -420,8 +420,7 @@ xrep_cow_alloc( if (error) return error; - error = xfs_alloc_vextent_start_ag(&args, - XFS_INO_TO_FSB(sc->mp, sc->ip->i_ino)); + error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(sc->ip)); if (error) return error; if (args.fsbno == NULLFSBLOCK) diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c index c2d6ad59d03e..d4e5afbde856 100644 --- a/fs/xfs/scrub/dabtree.c +++ b/fs/xfs/scrub/dabtree.c @@ -393,7 +393,7 @@ xchk_da_btree_block( /* Check the owner. */ if (xfs_has_crc(ip->i_mount)) { owner = be64_to_cpu(hdr3->owner); - if (owner != ip->i_ino) + if (owner != I_INO(ip)) xchk_da_set_corrupt(ds, level); } @@ -524,7 +524,7 @@ xchk_da_btree( ds->dargs.whichfork = whichfork; ds->dargs.trans = sc->tp; ds->dargs.op_flags = XFS_DA_OP_OKNOENT; - ds->dargs.owner = sc->ip->i_ino; + ds->dargs.owner = I_INO(sc->ip); ds->state = xfs_da_state_alloc(&ds->dargs); ds->sc = sc; ds->private = private; diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c index 09715a4aa154..2a037aae904d 100644 --- a/fs/xfs/scrub/dir.c +++ b/fs/xfs/scrub/dir.c @@ -187,11 +187,11 @@ xchk_dir_check_pptr_fast( if (!lockmode) { struct xchk_dirent save_de = { .namelen = name->len, - .ino = ip->i_ino, + .ino = I_INO(ip), }; /* Couldn't lock the inode, so save the dirent for later. */ - trace_xchk_dir_defer(sc->ip, name, ip->i_ino); + trace_xchk_dir_defer(sc->ip, name, I_INO(ip)); error = xfblob_storename(sd->dir_names, &save_de.name_cookie, name); @@ -254,14 +254,14 @@ xchk_dir_actor( if (xfs_dir2_samename(name, &xfs_name_dot)) { /* If this is "." then check that the inum matches the dir. */ - if (ino != dp->i_ino) + if (ino != I_INO(dp)) xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); } else if (xfs_dir2_samename(name, &xfs_name_dotdot)) { /* * If this is ".." in the root inode, check that the inum * matches this dir. */ - if (xchk_inode_is_dirtree_root(dp) && ino != dp->i_ino) + if (xchk_inode_is_dirtree_root(dp) && ino != I_INO(dp)) xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); } @@ -482,10 +482,10 @@ xchk_directory_data_bestfree( /* dir block format */ if (lblk != XFS_B_TO_FSBT(mp, XFS_DIR2_DATA_OFFSET)) xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, lblk); - error = xfs_dir3_block_read(sc->tp, sc->ip, sc->ip->i_ino, &bp); + error = xfs_dir3_block_read(sc->tp, sc->ip, I_INO(sc->ip), &bp); } else { /* dir data format */ - error = xfs_dir3_data_read(sc->tp, sc->ip, sc->ip->i_ino, lblk, + error = xfs_dir3_data_read(sc->tp, sc->ip, I_INO(sc->ip), lblk, 0, &bp); } if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error)) @@ -643,7 +643,7 @@ xchk_directory_leaf1_bestfree( int error; /* Read the free space block. */ - error = xfs_dir3_leaf_read(sc->tp, sc->ip, sc->ip->i_ino, lblk, &bp); + error = xfs_dir3_leaf_read(sc->tp, sc->ip, I_INO(sc->ip), lblk, &bp); if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error)) return error; xchk_buffer_recheck(sc, bp); @@ -749,7 +749,7 @@ xchk_directory_free_bestfree( int error; /* Read the free space block */ - error = xfs_dir2_free_read(sc->tp, sc->ip, sc->ip->i_ino, lblk, &bp); + error = xfs_dir2_free_read(sc->tp, sc->ip, I_INO(sc->ip), lblk, &bp); if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, lblk, &error)) return error; xchk_buffer_recheck(sc, bp); @@ -797,7 +797,7 @@ xchk_directory_blocks( .whichfork = XFS_DATA_FORK, .geo = sc->mp->m_dir_geo, .trans = sc->tp, - .owner = sc->ip->i_ino, + .owner = I_INO(sc->ip), }; struct xfs_ifork *ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK); struct xfs_mount *mp = sc->mp; @@ -996,7 +996,7 @@ xchk_dir_slow_dirent( */ lockmode = xchk_dir_lock_child(sc, ip); if (lockmode) { - trace_xchk_dir_slowpath(sc->ip, xname, ip->i_ino); + trace_xchk_dir_slowpath(sc->ip, xname, I_INO(ip)); goto check_pptr; } @@ -1007,7 +1007,7 @@ xchk_dir_slow_dirent( xchk_iunlock(sc, sc->ilock_flags); sd->need_revalidate = true; - trace_xchk_dir_ultraslowpath(sc->ip, xname, ip->i_ino); + trace_xchk_dir_ultraslowpath(sc->ip, xname, I_INO(ip)); error = xchk_dir_trylock_for_pptrs(sc, ip, &lockmode); if (error) @@ -1080,7 +1080,7 @@ xchk_directory( /* Plausible size? */ if (sc->ip->i_disk_size < xfs_dir2_sf_hdr_size(0)) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } diff --git a/fs/xfs/scrub/dir_repair.c b/fs/xfs/scrub/dir_repair.c index 23b80c54aa60..1c088cfba10e 100644 --- a/fs/xfs/scrub/dir_repair.c +++ b/fs/xfs/scrub/dir_repair.c @@ -304,7 +304,7 @@ xrep_dir_want_salvage( struct xfs_mount *mp = rd->sc->mp; /* No pointers to ourselves or to garbage. */ - if (ino == rd->sc->ip->i_ino) + if (ino == I_INO(rd->sc->ip)) return false; if (!xfs_verify_dir_ino(mp, ino)) return false; @@ -644,14 +644,14 @@ xrep_dir_recover_dirblock( case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC): if (!xrep_buf_verify_struct(bp, &xfs_dir3_block_buf_ops)) goto out; - if (xfs_dir3_block_header_check(bp, rd->sc->ip->i_ino) != NULL) + if (xfs_dir3_block_header_check(bp, I_INO(rd->sc->ip)) != NULL) goto out; break; case cpu_to_be32(XFS_DIR2_DATA_MAGIC): case cpu_to_be32(XFS_DIR3_DATA_MAGIC): if (!xrep_buf_verify_struct(bp, &xfs_dir3_data_buf_ops)) goto out; - if (xfs_dir3_data_header_check(bp, rd->sc->ip->i_ino) != NULL) + if (xfs_dir3_data_header_check(bp, I_INO(rd->sc->ip)) != NULL) goto out; break; default: @@ -676,7 +676,7 @@ xrep_dir_init_args( memset(&rd->args, 0, sizeof(struct xfs_da_args)); rd->args.geo = rd->sc->mp->m_dir_geo; rd->args.whichfork = XFS_DATA_FORK; - rd->args.owner = rd->sc->ip->i_ino; + rd->args.owner = I_INO(rd->sc->ip); rd->args.trans = rd->sc->tp; rd->args.dp = dp; if (!name) @@ -1125,12 +1125,12 @@ xrep_dir_scan_pptr( if (error) return error; - if (parent_ino != sc->ip->i_ino || + if (parent_ino != I_INO(sc->ip) || parent_gen != VFS_I(sc->ip)->i_generation) return 0; mutex_lock(&rd->pscan.lock); - error = xrep_dir_stash_createname(rd, &xname, ip->i_ino); + error = xrep_dir_stash_createname(rd, &xname, I_INO(ip)); mutex_unlock(&rd->pscan.lock); return error; } @@ -1151,7 +1151,7 @@ xrep_dir_scan_dirent( struct xrep_dir *rd = priv; /* Dirent doesn't point to this directory. */ - if (ino != rd->sc->ip->i_ino) + if (ino != I_INO(rd->sc->ip)) return 0; /* Ignore garbage inum. */ @@ -1168,9 +1168,9 @@ xrep_dir_scan_dirent( return 0; trace_xrep_dir_stash_createname(sc->tempip, &xfs_name_dotdot, - dp->i_ino); + I_INO(dp)); - xrep_findparent_scan_found(&rd->pscan, dp->i_ino); + xrep_findparent_scan_found(&rd->pscan, I_INO(dp)); return 0; } @@ -1281,7 +1281,7 @@ xrep_dir_scan_dirtree( /* Roots of directory trees are their own parents. */ if (xchk_inode_is_dirtree_root(sc->ip)) - xrep_findparent_scan_found(&rd->pscan, sc->ip->i_ino); + xrep_findparent_scan_found(&rd->pscan, I_INO(sc->ip)); /* * Filesystem scans are time consuming. Drop the directory ILOCK and @@ -1369,15 +1369,15 @@ xrep_dir_live_update( * rebuilding. Stash the update for replay against the temporary * directory. */ - if (p->dp->i_ino == sc->ip->i_ino && - xchk_iscan_want_live_update(&rd->pscan.iscan, p->ip->i_ino)) { + if (I_INO(p->dp) == I_INO(sc->ip) && + xchk_iscan_want_live_update(&rd->pscan.iscan, I_INO(p->ip))) { mutex_lock(&rd->pscan.lock); if (p->delta > 0) error = xrep_dir_stash_createname(rd, p->name, - p->ip->i_ino); + I_INO(p->ip)); else error = xrep_dir_stash_removename(rd, p->name, - p->ip->i_ino); + I_INO(p->ip)); mutex_unlock(&rd->pscan.lock); if (error) goto out_abort; @@ -1388,14 +1388,14 @@ xrep_dir_live_update( * the directory that we're rebuilding, so remember the new dotdot * target. */ - if (p->ip->i_ino == sc->ip->i_ino && - xchk_iscan_want_live_update(&rd->pscan.iscan, p->dp->i_ino)) { + if (I_INO(p->ip) == I_INO(sc->ip) && + xchk_iscan_want_live_update(&rd->pscan.iscan, I_INO(p->dp))) { if (p->delta > 0) { trace_xrep_dir_stash_createname(sc->tempip, &xfs_name_dotdot, - p->dp->i_ino); + I_INO(p->dp)); - xrep_findparent_scan_found(&rd->pscan, p->dp->i_ino); + xrep_findparent_scan_found(&rd->pscan, I_INO(p->dp)); } else { trace_xrep_dir_stash_removename(sc->tempip, &xfs_name_dotdot, @@ -1468,7 +1468,7 @@ xrep_dir_swap_prep( .whichfork = XFS_DATA_FORK, .trans = sc->tp, .total = 1, - .owner = sc->ip->i_ino, + .owner = I_INO(sc->ip), }; error = xfs_dir2_sf_to_block(&args); @@ -1576,7 +1576,7 @@ xrep_dir_set_nlink( * count. If the directory has no parent, it will be moved to the * orphanage. */ - pag = xfs_perag_get(sc->mp, XFS_INO_TO_AGNO(sc->mp, dp->i_ino)); + pag = xfs_perag_get(sc->mp, XFS_INODE_TO_AGNO(dp)); if (!pag) { ASSERT(0); return -EFSCORRUPTED; @@ -1764,7 +1764,7 @@ xrep_dir_rebuild_tree( * directory to an empty shortform directory because inactivation does * nothing for directories. */ - error = xrep_dir_reset_fork(rd, sc->mp->m_rootip->i_ino); + error = xrep_dir_reset_fork(rd, I_INO(sc->mp->m_rootip)); if (error) return error; diff --git a/fs/xfs/scrub/dirtree.c b/fs/xfs/scrub/dirtree.c index 143114718d75..c6a210f7508f 100644 --- a/fs/xfs/scrub/dirtree.c +++ b/fs/xfs/scrub/dirtree.c @@ -175,7 +175,7 @@ xchk_dirpath_append( if (error) return error; - error = xino_bitmap_set(&path->seen_inodes, ip->i_ino); + error = xino_bitmap_set(&path->seen_inodes, I_INO(ip)); if (error) return error; @@ -394,7 +394,7 @@ xchk_dirpath_step_up( * The inode being scanned is its own distant ancestor! Get rid of * this path. */ - if (parent_ino == sc->ip->i_ino) { + if (parent_ino == I_INO(sc->ip)) { xchk_dirpath_set_outcome(dl, path, XCHK_DIRPATH_DELETE); error = 0; goto out_scanlock; @@ -533,7 +533,7 @@ xchk_dirpath_walk_upwards( * The inode being scanned is its own direct ancestor! * Get rid of this path. */ - if (be64_to_cpu(dl->pptr_rec.p_ino) == sc->ip->i_ino) { + if (be64_to_cpu(dl->pptr_rec.p_ino) == I_INO(sc->ip)) { xchk_dirpath_set_outcome(dl, path, XCHK_DIRPATH_DELETE); return 0; } @@ -610,7 +610,7 @@ xchk_dirpath_step_is_stale( * If the parent and child being updated are not the ones mentioned in * this path step, the scan data is still ok. */ - if (p->ip->i_ino != child_ino || p->dp->i_ino != *cursor) + if (I_INO(p->ip) != child_ino || I_INO(p->dp) != *cursor) return 0; /* @@ -632,13 +632,13 @@ xchk_dirpath_step_is_stale( * If the update comes from the repair code itself, walk the state * machine forward. */ - if (p->ip->i_ino == dl->scan_ino && + if (I_INO(p->ip) == dl->scan_ino && path->outcome == XREP_DIRPATH_ADOPTING) { xchk_dirpath_set_outcome(dl, path, XREP_DIRPATH_ADOPTED); return 0; } - if (p->ip->i_ino == dl->scan_ino && + if (I_INO(p->ip) == dl->scan_ino && path->outcome == XREP_DIRPATH_DELETING) { xchk_dirpath_set_outcome(dl, path, XREP_DIRPATH_DELETED); return 0; @@ -669,7 +669,7 @@ xchk_dirpath_is_stale( * The child being updated has not been seen by this path at all; this * path cannot be stale. */ - if (!xino_bitmap_test(&path->seen_inodes, p->ip->i_ino)) + if (!xino_bitmap_test(&path->seen_inodes, I_INO(p->ip))) return 0; ret = xchk_dirpath_step_is_stale(dl, path, 0, idx, p, &cursor); @@ -928,7 +928,7 @@ xchk_dirtree( * released during teardown. */ dl->root_ino = xchk_inode_rootdir_inum(sc->ip); - dl->scan_ino = sc->ip->i_ino; + dl->scan_ino = I_INO(sc->ip); trace_xchk_dirtree_start(sc->ip, sc->sm, 0); @@ -954,7 +954,7 @@ xchk_dirtree( * parent pointers are corrupt; this scan cannot be completed * without full information. */ - xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_xref_set_corrupt(sc, sc->ip); error = 0; goto out_scanlock; } @@ -979,12 +979,12 @@ xchk_dirtree( xchk_dirtree_evaluate(dl, &oc); if (xchk_dirtree_parentless(dl)) { if (oc.good || oc.bad || oc.suspect) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); } else { if (oc.bad || oc.good + oc.suspect != 1) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); if (oc.suspect) - xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_xref_set_corrupt(sc, sc->ip); } out_scanlock: diff --git a/fs/xfs/scrub/dirtree_repair.c b/fs/xfs/scrub/dirtree_repair.c index bcfbbf5efc6c..1c0d7ea4a5be 100644 --- a/fs/xfs/scrub/dirtree_repair.c +++ b/fs/xfs/scrub/dirtree_repair.c @@ -459,7 +459,7 @@ xrep_dirtree_unlink( if (error) goto out_trans_cancel; - error = xfs_dir_removename(sc->tp, dp, &dl->xname, sc->ip->i_ino, + error = xfs_dir_removename(sc->tp, dp, &dl->xname, I_INO(sc->ip), resblks); if (error) { ASSERT(error != -ENOENT); @@ -583,7 +583,7 @@ xrep_dirtree_create_adoption_path( */ xfs_inode_to_parent_rec(&dl->pptr_rec, sc->orphanage); - error = xino_bitmap_set(&path->seen_inodes, sc->orphanage->i_ino); + error = xino_bitmap_set(&path->seen_inodes, I_INO(sc->orphanage)); if (error) goto out_path; diff --git a/fs/xfs/scrub/findparent.c b/fs/xfs/scrub/findparent.c index 2076f028d271..04b6b96b0a30 100644 --- a/fs/xfs/scrub/findparent.c +++ b/fs/xfs/scrub/findparent.c @@ -65,7 +65,7 @@ struct xrep_findparent_info { /* * Scrub context. We're looking for a @dp containing a directory - * entry pointing to sc->ip->i_ino. + * entry pointing to I_INO(sc->ip). */ struct xfs_scrub *sc; @@ -106,7 +106,7 @@ xrep_findparent_dirent( if (xchk_should_terminate(fpi->sc, &error)) return error; - if (ino != fpi->sc->ip->i_ino) + if (ino != I_INO(fpi->sc->ip)) return 0; /* Ignore garbage directory entry names. */ @@ -123,18 +123,18 @@ xrep_findparent_dirent( /* Uhoh, more than one parent for a dir? */ if (fpi->found_parent != NULLFSINO && - !(fpi->parent_tentative && fpi->found_parent == fpi->dp->i_ino)) { + !(fpi->parent_tentative && fpi->found_parent == I_INO(fpi->dp))) { trace_xrep_findparent_dirent(fpi->sc->ip, 0); return -EFSCORRUPTED; } /* We found a potential parent; remember this. */ - trace_xrep_findparent_dirent(fpi->sc->ip, fpi->dp->i_ino); - fpi->found_parent = fpi->dp->i_ino; + trace_xrep_findparent_dirent(fpi->sc->ip, I_INO(fpi->dp)); + fpi->found_parent = I_INO(fpi->dp); fpi->parent_tentative = false; if (fpi->parent_scan) - xrep_findparent_scan_found(fpi->parent_scan, fpi->dp->i_ino); + xrep_findparent_scan_found(fpi->parent_scan, I_INO(fpi->dp)); return 0; } @@ -227,13 +227,12 @@ xrep_findparent_live_update( * already scanned @p->dp, update the dotdot target inumber to the * parent inode. */ - if (p->ip->i_ino == sc->ip->i_ino && - xchk_iscan_want_live_update(&pscan->iscan, p->dp->i_ino)) { - if (p->delta > 0) { - xrep_findparent_scan_found(pscan, p->dp->i_ino); - } else { + if (I_INO(p->ip) == I_INO(sc->ip) && + xchk_iscan_want_live_update(&pscan->iscan, I_INO(p->dp))) { + if (p->delta > 0) + xrep_findparent_scan_found(pscan, I_INO(p->dp)); + else xrep_findparent_scan_found(pscan, NULLFSINO); - } } return NOTIFY_DONE; @@ -388,7 +387,7 @@ xrep_findparent_confirm( if (*parent_ino == NULLFSINO) return 0; if (!xfs_verify_dir_ino(sc->mp, *parent_ino) || - *parent_ino == sc->ip->i_ino) { + *parent_ino == I_INO(sc->ip)) { *parent_ino = NULLFSINO; return 0; } @@ -422,10 +421,10 @@ xfs_ino_t xrep_findparent_self_reference( struct xfs_scrub *sc) { - if (sc->ip->i_ino == sc->mp->m_sb.sb_rootino) + if (I_INO(sc->ip) == sc->mp->m_sb.sb_rootino) return sc->mp->m_sb.sb_rootino; - if (sc->ip->i_ino == sc->mp->m_sb.sb_metadirino) + if (I_INO(sc->ip) == sc->mp->m_sb.sb_metadirino) return sc->mp->m_sb.sb_metadirino; if (VFS_I(sc->ip)->i_nlink == 0) @@ -457,8 +456,8 @@ xrep_findparent_from_dcache( dput(parent); if (S_ISDIR(pip->i_mode)) { - trace_xrep_findparent_from_dcache(sc->ip, XFS_I(pip)->i_ino); - ret = XFS_I(pip)->i_ino; + ret = pip->i_ino; + trace_xrep_findparent_from_dcache(sc->ip, ret); } xchk_irele(sc, XFS_I(pip)); diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c index 911dc0f9a79d..19c0b1b2a787 100644 --- a/fs/xfs/scrub/ialloc.c +++ b/fs/xfs/scrub/ialloc.c @@ -363,6 +363,7 @@ xchk_iallocbt_check_cluster( struct xfs_inobt_rec_incore *irec, unsigned int cluster_base) { + struct xfs_perag *pag = to_perag(bs->cur->bc_group); struct xfs_imap imap; struct xfs_mount *mp = bs->cur->bc_mp; struct xfs_buf *cluster_bp; @@ -394,8 +395,7 @@ xchk_iallocbt_check_cluster( * ir_startino can be large enough to make im_boffset nonzero. */ ir_holemask = (irec->ir_holemask & cluster_mask); - imap.im_blkno = xfs_agbno_to_daddr(to_perag(bs->cur->bc_group), agbno); - imap.im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster); + imap.im_agbno = agbno; imap.im_boffset = XFS_INO_TO_OFFSET(mp, irec->ir_startino) << mp->m_sb.sb_inodelog; @@ -405,8 +405,8 @@ xchk_iallocbt_check_cluster( return 0; } - trace_xchk_iallocbt_check_cluster(to_perag(bs->cur->bc_group), - irec->ir_startino, imap.im_blkno, imap.im_len, + trace_xchk_iallocbt_check_cluster(pag, irec->ir_startino, imap.im_agbno, + XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), cluster_base, nr_inodes, cluster_mask, ir_holemask, XFS_INO_TO_OFFSET(mp, irec->ir_startino + cluster_base)); @@ -429,7 +429,8 @@ xchk_iallocbt_check_cluster( &XFS_RMAP_OINFO_INODES); /* Grab the inode cluster buffer. */ - error = xfs_imap_to_bp(mp, bs->cur->bc_tp, &imap, &cluster_bp); + error = xfs_read_icluster(pag, bs->cur->bc_tp, imap.im_agbno, + &cluster_bp); if (!xchk_btree_xref_process_error(bs->sc, bs->cur, 0, &error)) return error; diff --git a/fs/xfs/scrub/ialloc_repair.c b/fs/xfs/scrub/ialloc_repair.c index 608c7022ac15..46b1c8ac5543 100644 --- a/fs/xfs/scrub/ialloc_repair.c +++ b/fs/xfs/scrub/ialloc_repair.c @@ -287,7 +287,6 @@ xrep_ibt_process_cluster( struct xrep_ibt *ri, xfs_agblock_t cluster_bno) { - struct xfs_imap imap; struct xfs_buf *cluster_bp; struct xfs_scrub *sc = ri->sc; struct xfs_mount *mp = sc->mp; @@ -305,10 +304,8 @@ xrep_ibt_process_cluster( * inobt because imap_to_bp directly maps the buffer without touching * either inode btree. */ - imap.im_blkno = xfs_agbno_to_daddr(sc->sa.pag, cluster_bno); - imap.im_len = XFS_FSB_TO_BB(mp, igeo->blocks_per_cluster); - imap.im_boffset = 0; - error = xfs_imap_to_bp(mp, sc->tp, &imap, &cluster_bp); + error = xfs_read_icluster(sc->sa.pag, sc->tp, cluster_bno, + &cluster_bp); if (error) return error; diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c index 948d04dcba2a..65b13e311916 100644 --- a/fs/xfs/scrub/inode.c +++ b/fs/xfs/scrub/inode.c @@ -102,7 +102,7 @@ xchk_setup_inode( xchk_fsgates_enable(sc, XCHK_FSGATES_DRAIN); /* We want to scan the opened inode, so lock it and exit. */ - if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == ip_in->i_ino) { + if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == I_INO(ip_in)) { error = xchk_install_live_inode(sc, ip_in); if (error) return error; @@ -710,17 +710,17 @@ xchk_inode_xref_bmap( if (!xchk_should_check_xref(sc, &error, NULL)) return; if (nextents < xfs_dfork_data_extents(dip)) - xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_xref_set_corrupt(sc, sc->ip); error = xchk_inode_count_blocks(sc, XFS_ATTR_FORK, &nextents, &acount); if (!xchk_should_check_xref(sc, &error, NULL)) return; if (nextents != xfs_dfork_attr_extents(dip)) - xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_xref_set_corrupt(sc, sc->ip); /* Check nblocks against the inode. */ if (count + acount != be64_to_cpu(dip->di_nblocks)) - xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_xref_set_corrupt(sc, sc->ip); } /* Cross-reference with the other btrees. */ @@ -794,10 +794,10 @@ xchk_inode_check_unlinked( { if (VFS_I(sc->ip)->i_nlink == 0) { if (!xfs_inode_on_unlinked_list(sc->ip)) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ino_set_corrupt(sc, I_INO(sc->ip)); } else { if (xfs_inode_on_unlinked_list(sc->ip)) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ino_set_corrupt(sc, I_INO(sc->ip)); } } @@ -821,7 +821,7 @@ xchk_inode( /* Scrub the inode core. */ xfs_inode_to_disk(sc->ip, &di, 0); - xchk_dinode(sc, &di, sc->ip->i_ino); + xchk_dinode(sc, &di, I_INO(sc->ip)); if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) goto out; @@ -831,11 +831,11 @@ xchk_inode( * we scrubbed the dinode. */ if (S_ISREG(VFS_I(sc->ip)->i_mode)) - xchk_inode_check_reflink_iflag(sc, sc->ip->i_ino); + xchk_inode_check_reflink_iflag(sc, I_INO(sc->ip)); xchk_inode_check_unlinked(sc); - xchk_inode_xref(sc, sc->ip->i_ino, &di); + xchk_inode_xref(sc, I_INO(sc->ip), &di); out: return error; } diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c index 9738b9ce3f2d..493dcf5cc6c1 100644 --- a/fs/xfs/scrub/inode_repair.c +++ b/fs/xfs/scrub/inode_repair.c @@ -1547,6 +1547,7 @@ xrep_dinode_core( struct xrep_inode *ri) { struct xfs_scrub *sc = ri->sc; + struct xfs_mount *mp = sc->mp; struct xfs_buf *bp; struct xfs_dinode *dip; xfs_ino_t ino = sc->sm->sm_ino; @@ -1559,8 +1560,11 @@ xrep_dinode_core( return error; /* Read the inode cluster buffer. */ - error = xfs_trans_read_buf(sc->mp, sc->tp, sc->mp->m_ddev_targp, - ri->imap.im_blkno, ri->imap.im_len, 0, &bp, NULL); + error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp, + XFS_AGB_TO_DADDR(mp, XFS_INO_TO_AGNO(mp, ino), + ri->imap.im_agbno), + XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster), + 0, &bp, NULL); if (error) return error; @@ -1583,10 +1587,10 @@ xrep_dinode_core( write: /* Write out the inode. */ trace_xrep_dinode_fixed(sc, dip); - xfs_dinode_calc_crc(sc->mp, dip); + xfs_dinode_calc_crc(mp, dip); xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_DINO_BUF); xfs_trans_log_buf(sc->tp, bp, ri->imap.im_boffset, - ri->imap.im_boffset + sc->mp->m_sb.sb_inodesize - 1); + ri->imap.im_boffset + mp->m_sb.sb_inodesize - 1); /* * In theory, we've fixed the ondisk inode record enough that we should @@ -1796,7 +1800,7 @@ xrep_inode_flags( sc->ip->i_diflags &= ~XFS_DIFLAG_ANY; /* NEWRTBM only applies to realtime bitmaps */ - if (sc->ip->i_ino == sc->mp->m_sb.sb_rbmino) + if (I_INO(sc->ip) == sc->mp->m_sb.sb_rbmino) sc->ip->i_diflags |= XFS_DIFLAG_NEWRTBM; else sc->ip->i_diflags &= ~XFS_DIFLAG_NEWRTBM; @@ -2011,8 +2015,7 @@ xrep_inode_unlinked( struct xfs_perag *pag; int error; - pag = xfs_perag_get(sc->mp, - XFS_INO_TO_AGNO(sc->mp, sc->ip->i_ino)); + pag = xfs_perag_get(sc->mp, XFS_INODE_TO_AGNO(sc->ip)); error = xfs_iunlink_remove(sc->tp, pag, sc->ip); xfs_perag_put(pag); if (error) diff --git a/fs/xfs/scrub/iscan.c b/fs/xfs/scrub/iscan.c index 2a974eed00cc..03f72ba9e7a3 100644 --- a/fs/xfs/scrub/iscan.c +++ b/fs/xfs/scrub/iscan.c @@ -728,7 +728,7 @@ xchk_iscan_mark_visited( struct xfs_inode *ip) { mutex_lock(&iscan->lock); - iscan->__visited_ino = ip->i_ino; + iscan->__visited_ino = I_INO(ip); trace_xchk_iscan_visit(iscan); mutex_unlock(&iscan->lock); } diff --git a/fs/xfs/scrub/listxattr.c b/fs/xfs/scrub/listxattr.c index 0863db64b1b2..9b4cf393788b 100644 --- a/fs/xfs/scrub/listxattr.c +++ b/fs/xfs/scrub/listxattr.c @@ -115,7 +115,7 @@ xchk_xattr_walk_leaf( struct xfs_buf *leaf_bp; int error; - error = xfs_attr3_leaf_read(sc->tp, ip, ip->i_ino, 0, &leaf_bp); + error = xfs_attr3_leaf_read(sc->tp, ip, I_INO(ip), 0, &leaf_bp); if (error) return error; @@ -166,7 +166,7 @@ xchk_xattr_find_leftmost_leaf( magic != XFS_DA3_NODE_MAGIC) goto out_buf; - fa = xfs_da3_node_header_check(bp, ip->i_ino); + fa = xfs_da3_node_header_check(bp, I_INO(ip)); if (fa) goto out_buf; @@ -195,7 +195,7 @@ xchk_xattr_find_leftmost_leaf( } error = -EFSCORRUPTED; - fa = xfs_attr3_leaf_header_check(bp, ip->i_ino); + fa = xfs_attr3_leaf_header_check(bp, I_INO(ip)); if (fa) goto out_buf; @@ -266,8 +266,8 @@ xchk_xattr_walk_node( goto out_bitmap; } - error = xfs_attr3_leaf_read(sc->tp, ip, ip->i_ino, - leafhdr.forw, &leaf_bp); + error = xfs_attr3_leaf_read(sc->tp, ip, I_INO(ip), leafhdr.forw, + &leaf_bp); if (error) goto out_bitmap; diff --git a/fs/xfs/scrub/metapath.c b/fs/xfs/scrub/metapath.c index 050b86eb12d3..ff1ff762b300 100644 --- a/fs/xfs/scrub/metapath.c +++ b/fs/xfs/scrub/metapath.c @@ -314,7 +314,7 @@ xchk_metapath( /* Parent required to do anything else. */ if (mpath->dp == NULL) { - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); return 0; } @@ -329,15 +329,15 @@ xchk_metapath( trace_xchk_metapath_lookup(sc, mpath->path, mpath->dp, ino); if (error == -ENOENT) { /* No directory entry at all */ - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); error = 0; goto out_ilock; } if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error)) goto out_ilock; - if (ino != sc->ip->i_ino) { + if (ino != I_INO(sc->ip)) { /* Pointing to wrong inode */ - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); } out_ilock: @@ -364,7 +364,7 @@ xrep_metapath_link( else mpath->du.ppargs = NULL; - trace_xrep_metapath_link(sc, mpath->path, mpath->dp, sc->ip->i_ino); + trace_xrep_metapath_link(sc, mpath->path, mpath->dp, I_INO(sc->ip)); return xfs_dir_add_child(sc->tp, mpath->link_resblks, &mpath->du); } @@ -462,7 +462,7 @@ xrep_metapath_try_link( if (error) goto out_cancel; - if (ino == sc->ip->i_ino) { + if (ino == I_INO(sc->ip)) { /* The dirent already points to @sc->ip; we're done. */ error = 0; goto out_cancel; @@ -530,7 +530,7 @@ xrep_metapath_try_unlink( xfs_ino_t ino; int error; - ASSERT(*alleged_child != sc->ip->i_ino); + ASSERT(*alleged_child != I_INO(sc->ip)); trace_xrep_metapath_try_unlink(sc, mpath->path, mpath->dp, *alleged_child); @@ -575,7 +575,7 @@ xrep_metapath_try_unlink( if (error) goto out_cancel; - if (ino == sc->ip->i_ino) { + if (ino == I_INO(sc->ip)) { /* The dirent already points to @sc->ip; we're done. */ error = -EEXIST; goto out_cancel; diff --git a/fs/xfs/scrub/newbt.c b/fs/xfs/scrub/newbt.c index 2e4981c1baf2..c82f4631fd9c 100644 --- a/fs/xfs/scrub/newbt.c +++ b/fs/xfs/scrub/newbt.c @@ -123,8 +123,7 @@ xrep_newbt_init_inode( if (!ifp) return -ENOMEM; - xrep_newbt_init_ag(xnr, sc, oinfo, - XFS_INO_TO_FSB(sc->mp, sc->ip->i_ino), + xrep_newbt_init_ag(xnr, sc, oinfo, XFS_INODE_TO_FSB(sc->ip), XFS_AG_RESV_NONE); xnr->ifake.if_fork = ifp; xnr->ifake.if_fork_size = xfs_inode_fork_size(sc->ip, whichfork); @@ -146,7 +145,7 @@ xrep_newbt_init_metadir_inode( ASSERT(xfs_is_metadir_inode(sc->ip)); - xfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, XFS_DATA_FORK); + xfs_rmap_inode_bmbt_owner(&oinfo, sc->ip, XFS_DATA_FORK); ifp = kmem_cache_zalloc(xfs_ifork_cache, XCHK_GFP_FLAGS); if (!ifp) @@ -160,8 +159,7 @@ xrep_newbt_init_metadir_inode( * as if they were regular file blocks. This exposes us to a higher * risk of the repair being cancelled due to ENOSPC. */ - xrep_newbt_init_ag(xnr, sc, &oinfo, - XFS_INO_TO_FSB(sc->mp, sc->ip->i_ino), + xrep_newbt_init_ag(xnr, sc, &oinfo, XFS_INODE_TO_FSB(sc->ip), XFS_AG_RESV_NONE); xnr->ifake.if_fork = ifp; xnr->ifake.if_fork_size = xfs_inode_fork_size(sc->ip, XFS_DATA_FORK); diff --git a/fs/xfs/scrub/nlinks.c b/fs/xfs/scrub/nlinks.c index 1e0effdb65a6..355ab6de23ea 100644 --- a/fs/xfs/scrub/nlinks.c +++ b/fs/xfs/scrub/nlinks.c @@ -175,7 +175,7 @@ xchk_nlinks_live_update( if (xrep_is_tempfile(p->dp)) return NOTIFY_DONE; - trace_xchk_nlinks_live_update(xnc->sc->mp, p->dp, action, p->ip->i_ino, + trace_xchk_nlinks_live_update(xnc->sc->mp, p->dp, action, I_INO(p->ip), p->delta, p->name->name, p->name->len); /* @@ -183,12 +183,12 @@ xchk_nlinks_live_update( * to @ip. If @ip is a subdirectory, update the number of child links * going out of @dp. */ - if (xchk_iscan_want_live_update(&xnc->collect_iscan, p->dp->i_ino)) { + if (xchk_iscan_want_live_update(&xnc->collect_iscan, I_INO(p->dp))) { mutex_lock(&xnc->lock); - error = xchk_nlinks_update_incore(xnc, p->ip->i_ino, p->delta, + error = xchk_nlinks_update_incore(xnc, I_INO(p->ip), p->delta, 0, 0); if (!error && S_ISDIR(VFS_IC(p->ip)->i_mode)) - error = xchk_nlinks_update_incore(xnc, p->dp->i_ino, 0, + error = xchk_nlinks_update_incore(xnc, I_INO(p->dp), 0, 0, p->delta); mutex_unlock(&xnc->lock); if (error) @@ -200,9 +200,9 @@ xchk_nlinks_live_update( * number of backrefs pointing to @dp. */ if (S_ISDIR(VFS_IC(p->ip)->i_mode) && - xchk_iscan_want_live_update(&xnc->collect_iscan, p->ip->i_ino)) { + xchk_iscan_want_live_update(&xnc->collect_iscan, I_INO(p->ip))) { mutex_lock(&xnc->lock); - error = xchk_nlinks_update_incore(xnc, p->dp->i_ino, 0, + error = xchk_nlinks_update_incore(xnc, I_INO(p->dp), 0, p->delta, 0); mutex_unlock(&xnc->lock); if (error) @@ -243,7 +243,7 @@ xchk_nlinks_collect_dirent( dotdot = true; /* Don't accept a '.' entry that points somewhere else. */ - if (dot && ino != dp->i_ino) { + if (dot && ino != I_INO(dp)) { error = -ECANCELED; goto out_abort; } @@ -304,7 +304,7 @@ xchk_nlinks_collect_dirent( * number of child links of dp. */ if (!dot && !dotdot && name->type == XFS_DIR3_FT_DIR) { - error = xchk_nlinks_update_incore(xnc, dp->i_ino, 0, 0, 1); + error = xchk_nlinks_update_incore(xnc, I_INO(dp), 0, 0, 1); if (error) goto out_unlock; } @@ -692,7 +692,7 @@ xchk_nlinks_compare_inode( goto out_scanlock; } - error = xchk_nlinks_comparison_read(xnc, ip->i_ino, &obs); + error = xchk_nlinks_comparison_read(xnc, I_INO(ip), &obs); if (error) goto out_scanlock; @@ -718,15 +718,15 @@ xchk_nlinks_compare_inode( * count, but it will let them decrease it. */ if (total_links > XFS_NLINK_PINNED) { - xchk_ino_set_corrupt(sc, ip->i_ino); + xchk_ip_set_corrupt(sc, ip); goto out_corrupt; } else if (total_links > XFS_MAXLINK) { - xchk_ino_set_warning(sc, ip->i_ino); + xchk_ino_set_warning(sc, I_INO(ip)); } /* Link counts should match. */ if (total_links != actual_nlink) { - xchk_ino_set_corrupt(sc, ip->i_ino); + xchk_ip_set_corrupt(sc, ip); goto out_corrupt; } @@ -740,14 +740,14 @@ xchk_nlinks_compare_inode( * number of subdirectory entries in the directory. */ if (obs.children != obs.backrefs) - xchk_ino_xref_set_corrupt(sc, ip->i_ino); + xchk_ip_xref_set_corrupt(sc, ip); } else { /* * Non-directories and unlinked directories should not have * back references. */ if (obs.backrefs != 0) { - xchk_ino_set_corrupt(sc, ip->i_ino); + xchk_ip_set_corrupt(sc, ip); goto out_corrupt; } @@ -756,7 +756,7 @@ xchk_nlinks_compare_inode( * children. */ if (obs.children != 0) { - xchk_ino_set_corrupt(sc, ip->i_ino); + xchk_ip_set_corrupt(sc, ip); goto out_corrupt; } } @@ -769,7 +769,7 @@ xchk_nlinks_compare_inode( * the root directory. */ if (obs.parents != 1) { - xchk_ino_set_corrupt(sc, ip->i_ino); + xchk_ip_set_corrupt(sc, ip); goto out_corrupt; } } else if (actual_nlink > 0) { @@ -778,7 +778,7 @@ xchk_nlinks_compare_inode( * least one parent. */ if (obs.parents == 0) { - xchk_ino_set_corrupt(sc, ip->i_ino); + xchk_ip_set_corrupt(sc, ip); goto out_corrupt; } } diff --git a/fs/xfs/scrub/nlinks_repair.c b/fs/xfs/scrub/nlinks_repair.c index 9049215c6eae..fbc2ff809fc0 100644 --- a/fs/xfs/scrub/nlinks_repair.c +++ b/fs/xfs/scrub/nlinks_repair.c @@ -75,7 +75,7 @@ xrep_nlinks_iunlink_remove( struct xfs_perag *pag; int error; - pag = xfs_perag_get(sc->mp, XFS_INO_TO_AGNO(sc->mp, sc->ip->i_ino)); + pag = xfs_perag_get(sc->mp, XFS_INODE_TO_AGNO(sc->ip)); error = xfs_iunlink_remove(sc->tp, pag, sc->ip); xfs_perag_put(pag); return error; @@ -152,7 +152,7 @@ xrep_nlinks_repair_inode( goto out_scanlock; } - error = xfarray_load_sparse(xnc->nlinks, ip->i_ino, &obs); + error = xfarray_load_sparse(xnc->nlinks, I_INO(ip), &obs); if (error) goto out_scanlock; @@ -206,7 +206,7 @@ xrep_nlinks_repair_inode( * updated our scan info. */ mutex_lock(&xnc->lock); - error = xfarray_load_sparse(xnc->nlinks, ip->i_ino, &obs); + error = xfarray_load_sparse(xnc->nlinks, I_INO(ip), &obs); mutex_unlock(&xnc->lock); if (error) goto out_trans; diff --git a/fs/xfs/scrub/orphanage.c b/fs/xfs/scrub/orphanage.c index 33c6db6b4498..3aca66869b80 100644 --- a/fs/xfs/scrub/orphanage.c +++ b/fs/xfs/scrub/orphanage.c @@ -402,14 +402,14 @@ xrep_adoption_compute_name( int error = 0; adopt->xname = xname; - xname->len = snprintf(namebuf, MAXNAMELEN, "%llu", sc->ip->i_ino); + xname->len = snprintf(namebuf, MAXNAMELEN, "%llu", I_INO(sc->ip)); xname->type = xfs_mode_to_ftype(VFS_I(sc->ip)->i_mode); /* Make sure the filename is unique in the lost+found. */ error = xchk_dir_lookup(sc, sc->orphanage, xname, &ino); while (error == 0 && incr < 10000) { xname->len = snprintf(namebuf, MAXNAMELEN, "%llu.%u", - sc->ip->i_ino, ++incr); + I_INO(sc->ip), ++incr); error = xchk_dir_lookup(sc, sc->orphanage, xname, &ino); } if (error == 0) { @@ -532,7 +532,7 @@ xrep_adoption_move( int error; trace_xrep_adoption_reparent(sc->orphanage, adopt->xname, - sc->ip->i_ino); + I_INO(sc->ip)); error = xrep_adoption_check_dcache(adopt); if (error) @@ -553,7 +553,7 @@ xrep_adoption_move( /* Create the new name in the orphanage. */ error = xfs_dir_createname(sc->tp, sc->orphanage, adopt->xname, - sc->ip->i_ino, adopt->orphanage_blkres); + I_INO(sc->ip), adopt->orphanage_blkres); if (error) return error; @@ -576,7 +576,7 @@ xrep_adoption_move( /* Replace the dotdot entry if the child is a subdirectory. */ if (isdir) { error = xfs_dir_replace(sc->tp, sc->ip, &xfs_name_dotdot, - sc->orphanage->i_ino, adopt->child_blkres); + I_INO(sc->orphanage), adopt->child_blkres); if (error) return error; } diff --git a/fs/xfs/scrub/parent.c b/fs/xfs/scrub/parent.c index 931604fa1294..a8c4807e1d94 100644 --- a/fs/xfs/scrub/parent.c +++ b/fs/xfs/scrub/parent.c @@ -72,7 +72,7 @@ xchk_parent_actor( if (!xchk_fblock_xref_process_error(sc, XFS_DATA_FORK, 0, &error)) return error; - if (sc->ip->i_ino == ino) + if (I_INO(sc->ip) == ino) spc->nlink++; if (xchk_should_terminate(spc->sc, &error)) @@ -119,6 +119,7 @@ xchk_parent_validate( .nlink = 0, }; struct xfs_mount *mp = sc->mp; + xfs_ino_t ino = I_INO(sc->ip); struct xfs_inode *dp = NULL; xfs_nlink_t expected_nlink; unsigned int lock_mode; @@ -126,22 +127,20 @@ xchk_parent_validate( /* Is this the root dir? Then '..' must point to itself. */ if (sc->ip == mp->m_rootip) { - if (sc->ip->i_ino != mp->m_sb.sb_rootino || - sc->ip->i_ino != parent_ino) + if (ino != mp->m_sb.sb_rootino || ino != parent_ino) xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); return 0; } /* Is this the metadata root dir? Then '..' must point to itself. */ if (sc->ip == mp->m_metadirip) { - if (sc->ip->i_ino != mp->m_sb.sb_metadirino || - sc->ip->i_ino != parent_ino) + if (ino != mp->m_sb.sb_metadirino || ino != parent_ino) xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); return 0; } /* '..' must not point to ourselves. */ - if (sc->ip->i_ino == parent_ino) { + if (ino == parent_ino) { xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); return 0; } @@ -315,7 +314,7 @@ xchk_parent_pptr_and_dotdot( /* Is this the root dir? Then '..' must point to itself. */ if (xchk_inode_is_dirtree_root(sc->ip)) { - if (sc->ip->i_ino != pp->parent_ino) + if (I_INO(sc->ip) != pp->parent_ino) xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); return 0; } @@ -398,7 +397,7 @@ xchk_parent_dirent( return error; /* Does the inode number match? */ - if (child_ino != sc->ip->i_ino) { + if (child_ino != I_INO(sc->ip)) { xchk_fblock_xref_set_corrupt(sc, XFS_ATTR_FORK, 0); return 0; } @@ -490,7 +489,7 @@ xchk_parent_scan_attr( } /* No self-referential parent pointers. */ - if (parent_ino == sc->ip->i_ino) { + if (parent_ino == I_INO(sc->ip)) { xchk_fblock_set_corrupt(sc, XFS_ATTR_FORK, 0); return -ECANCELED; } @@ -512,7 +511,7 @@ xchk_parent_scan_attr( }; /* Couldn't lock the inode, so save the pptr for later. */ - trace_xchk_parent_defer(sc->ip, &xname, dp->i_ino); + trace_xchk_parent_defer(sc->ip, &xname, I_INO(dp)); error = xfblob_storename(pp->pptr_names, &save_pp.name_cookie, &xname); @@ -599,7 +598,7 @@ xchk_parent_slow_pptr( */ lockmode = xchk_parent_lock_dir(sc, dp); if (lockmode) { - trace_xchk_parent_slowpath(sc->ip, xname, dp->i_ino); + trace_xchk_parent_slowpath(sc->ip, xname, I_INO(dp)); goto check_dirent; } @@ -610,7 +609,7 @@ xchk_parent_slow_pptr( xchk_iunlock(sc, sc->ilock_flags); pp->need_revalidate = true; - trace_xchk_parent_ultraslowpath(sc->ip, xname, dp->i_ino); + trace_xchk_parent_ultraslowpath(sc->ip, xname, I_INO(dp)); error = xchk_dir_trylock_for_pptrs(sc, dp, &lockmode); if (error) @@ -729,10 +728,10 @@ xchk_parent_count_pptrs( pp->pptrs_found++; if (VFS_I(sc->ip)->i_nlink == 0 && pp->pptrs_found > 0) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); else if (VFS_I(sc->ip)->i_nlink > 0 && pp->pptrs_found == 0) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); } else { /* * Starting with metadir, we allow checking of parent pointers @@ -743,7 +742,7 @@ xchk_parent_count_pptrs( pp->pptrs_found++; if (VFS_I(sc->ip)->i_nlink != pp->pptrs_found) - xchk_ino_set_corrupt(sc, sc->ip->i_ino); + xchk_ip_set_corrupt(sc, sc->ip); } return 0; @@ -856,7 +855,7 @@ xchk_parent( return -ENOENT; /* We're not a special inode, are we? */ - if (!xfs_verify_dir_ino(mp, sc->ip->i_ino)) { + if (!xfs_verify_dir_ino(mp, I_INO(sc->ip))) { xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0); return 0; } diff --git a/fs/xfs/scrub/parent_repair.c b/fs/xfs/scrub/parent_repair.c index 2ce0cefad362..f643724910f9 100644 --- a/fs/xfs/scrub/parent_repair.c +++ b/fs/xfs/scrub/parent_repair.c @@ -302,14 +302,14 @@ xrep_parent_replay_update( trace_xrep_parent_replay_parentadd(sc->tempip, xname, &pptr->pptr_rec); - return xfs_parent_set(sc->tempip, sc->ip->i_ino, xname, + return xfs_parent_set(sc->tempip, I_INO(sc->ip), xname, &pptr->pptr_rec, &rp->pptr_args); case XREP_PPTR_REMOVE: /* Remove parent pointer. */ trace_xrep_parent_replay_parentremove(sc->tempip, xname, &pptr->pptr_rec); - return xfs_parent_unset(sc->tempip, sc->ip->i_ino, xname, + return xfs_parent_unset(sc->tempip, I_INO(sc->ip), xname, &pptr->pptr_rec, &rp->pptr_args); } @@ -434,7 +434,7 @@ xrep_parent_scan_dirent( int error; /* Dirent doesn't point to this directory. */ - if (ino != rp->sc->ip->i_ino) + if (ino != I_INO(rp->sc->ip)) return 0; /* No weird looking names. */ @@ -645,8 +645,8 @@ xrep_parent_live_update( * repairing, so stash the update for replay against the temporary * file. */ - if (p->ip->i_ino == sc->ip->i_ino && - xchk_iscan_want_live_update(&rp->pscan.iscan, p->dp->i_ino)) { + if (I_INO(p->ip) == I_INO(sc->ip) && + xchk_iscan_want_live_update(&rp->pscan.iscan, I_INO(p->dp))) { mutex_lock(&rp->pscan.lock); if (p->delta > 0) error = xrep_parent_stash_parentadd(rp, p->name, p->dp); @@ -906,7 +906,7 @@ xrep_parent_fetch_xattr_remote( .namelen = namelen, .trans = sc->tp, .valuelen = valuelen, - .owner = ip->i_ino, + .owner = I_INO(ip), }; int error; @@ -984,7 +984,7 @@ xrep_parent_insert_xattr( .attr_filter = key->flags, .namelen = key->namelen, .valuelen = key->valuelen, - .owner = rp->sc->ip->i_ino, + .owner = I_INO(rp->sc->ip), .geo = rp->sc->mp->m_attr_geo, .whichfork = XFS_ATTR_FORK, .op_flags = XFS_DA_OP_OKNOENT, @@ -1329,7 +1329,7 @@ xrep_parent_rebuild_pptrs( * For this purpose, root directories are their own parents. */ if (xchk_inode_is_dirtree_root(sc->ip)) { - xrep_findparent_scan_found(&rp->pscan, sc->ip->i_ino); + xrep_findparent_scan_found(&rp->pscan, I_INO(sc->ip)); } else { error = xrep_parent_lookup_pptrs(sc, &parent_ino); if (error) @@ -1451,7 +1451,7 @@ xrep_parent_set_nondir_nlink( * The file is on the unlinked list but we found parents. * Remove the file from the unlinked list. */ - pag = xfs_perag_get(sc->mp, XFS_INO_TO_AGNO(sc->mp, ip->i_ino)); + pag = xfs_perag_get(sc->mp, XFS_INODE_TO_AGNO(ip)); if (!pag) { ASSERT(0); return -EFSCORRUPTED; diff --git a/fs/xfs/scrub/quotacheck.c b/fs/xfs/scrub/quotacheck.c index 9ea014e2ecfd..c199d128538e 100644 --- a/fs/xfs/scrub/quotacheck.c +++ b/fs/xfs/scrub/quotacheck.c @@ -399,7 +399,7 @@ xqcheck_collect_inode( int error = 0; if (xfs_is_metadir_inode(ip) || - xfs_is_quota_inode(&tp->t_mountp->m_sb, ip->i_ino)) { + xfs_is_quota_inode(&tp->t_mountp->m_sb, I_INO(ip))) { /* * Quota files are never counted towards quota, so we do not * need to take the lock. Files do not switch between the diff --git a/fs/xfs/scrub/readdir.c b/fs/xfs/scrub/readdir.c index c66ec9093a38..d68bf20b4a14 100644 --- a/fs/xfs/scrub/readdir.c +++ b/fs/xfs/scrub/readdir.c @@ -50,7 +50,7 @@ xchk_dir_walk_sf( dapos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk, geo->data_entry_offset); - error = dirent_fn(sc, dp, dapos, &name, dp->i_ino, priv); + error = dirent_fn(sc, dp, dapos, &name, I_INO(dp), priv); if (error) return error; @@ -100,7 +100,7 @@ xchk_dir_walk_block( unsigned int off, next_off, end; int error; - error = xfs_dir3_block_read(sc->tp, dp, dp->i_ino, &bp); + error = xfs_dir3_block_read(sc->tp, dp, I_INO(dp), &bp); if (error) return error; @@ -176,7 +176,7 @@ xchk_read_leaf_dir_buf( if (new_off > *curoff) *curoff = new_off; - return xfs_dir3_data_read(tp, dp, dp->i_ino, map.br_startoff, 0, bpp); + return xfs_dir3_data_read(tp, dp, I_INO(dp), map.br_startoff, 0, bpp); } /* Call a function for every entry in a leaf directory. */ @@ -274,7 +274,7 @@ xchk_dir_walk( .dp = dp, .geo = dp->i_mount->m_dir_geo, .trans = sc->tp, - .owner = dp->i_ino, + .owner = I_INO(dp), }; int error; @@ -320,7 +320,7 @@ xchk_dir_lookup( .hashval = xfs_dir2_hashname(dp->i_mount, name), .whichfork = XFS_DATA_FORK, .op_flags = XFS_DA_OP_OKNOENT, - .owner = dp->i_ino, + .owner = I_INO(dp), }; int error; @@ -332,7 +332,7 @@ xchk_dir_lookup( * set to sc->ip, so we must switch the owner here for the lookup. */ if (dp == sc->tempip) - args.owner = sc->ip->i_ino; + args.owner = I_INO(sc->ip); ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); xfs_assert_ilocked(dp, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL); diff --git a/fs/xfs/scrub/reap.c b/fs/xfs/scrub/reap.c index fff23932828b..fcd14c1703ea 100644 --- a/fs/xfs/scrub/reap.c +++ b/fs/xfs/scrub/reap.c @@ -1205,7 +1205,7 @@ xrep_reap_metadir_fsblocks( ASSERT(xfs_is_metadir_inode(sc->ip)); xreap_configure_agextent_limits(&rs); - xfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, XFS_DATA_FORK); + xfs_rmap_inode_bmbt_owner(&oinfo, sc->ip, XFS_DATA_FORK); error = xfsb_bitmap_walk(bitmap, xreap_fsmeta_extent, &rs); if (error) return error; @@ -1249,8 +1249,7 @@ xreap_bmapi_select( cur = xfs_rmapbt_init_cursor(sc->mp, sc->tp, sc->sa.agf_bp, sc->sa.pag); - xfs_rmap_ino_owner(&oinfo, rs->ip->i_ino, rs->whichfork, - imap->br_startoff); + xfs_rmap_inode_owner(&oinfo, rs->ip, rs->whichfork, imap->br_startoff); error = xfs_rmap_has_other_keys(cur, agbno, 1, &oinfo, crosslinked); if (error) goto out_cur; diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c index ac8c592579bd..11697a8b2a1d 100644 --- a/fs/xfs/scrub/repair.c +++ b/fs/xfs/scrub/repair.c @@ -816,7 +816,7 @@ xrep_ino_dqattach( case -ENOENT: xfs_err_ratelimited(sc->mp, "inode %llu repair encountered quota error %d, quotacheck forced.", - (unsigned long long)sc->ip->i_ino, error); + (unsigned long long)I_INO(sc->ip), error); if (XFS_IS_UQUOTA_ON(sc->mp) && !sc->ip->i_udquot) xrep_force_quotacheck(sc, XFS_DQTYPE_USER); if (XFS_IS_GQUOTA_ON(sc->mp) && !sc->ip->i_gdquot) diff --git a/fs/xfs/scrub/rmap_repair.c b/fs/xfs/scrub/rmap_repair.c index 6766df9922e8..590f9f41856e 100644 --- a/fs/xfs/scrub/rmap_repair.c +++ b/fs/xfs/scrub/rmap_repair.c @@ -570,7 +570,7 @@ xrep_rmap_scan_ifork( int whichfork) { struct xrep_rmap_ifork rf = { - .accum = { .rm_owner = ip->i_ino, }, + .accum = { .rm_owner = I_INO(ip), }, .rr = rr, .whichfork = whichfork, }; diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c index b3a4972d423e..de3f22f310f7 100644 --- a/fs/xfs/scrub/rtbitmap.c +++ b/fs/xfs/scrub/rtbitmap.c @@ -200,13 +200,13 @@ xchk_rtbitmap( /* Is sb_rextents correct? */ if (mp->m_sb.sb_rextents != rtb->rextents) { - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } /* Is sb_rextslog correct? */ if (mp->m_sb.sb_rextslog != rtb->rextslog) { - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } @@ -215,17 +215,17 @@ xchk_rtbitmap( * case can we exceed 4bn bitmap blocks since the super field is a u32. */ if (rtb->rbmblocks > U32_MAX) { - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } if (mp->m_sb.sb_rbmblocks != rtb->rbmblocks) { - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } /* The bitmap file length must be aligned to an fsblock. */ if (rbmip->i_disk_size & mp->m_blockmask) { - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } @@ -235,7 +235,7 @@ xchk_rtbitmap( * file can be larger than sb_rbmblocks. */ if (rbmip->i_disk_size < XFS_FSB_TO_B(mp, rtb->rbmblocks)) { - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } @@ -284,7 +284,7 @@ xchk_xref_is_used_rt_space( if (xfs_has_zoned(sc->mp)) { if (!xfs_zone_rgbno_is_valid(rtg, xfs_rtb_to_rgbno(sc->mp, rtbno) + len - 1)) - xchk_ino_xref_set_corrupt(sc, rtg_rmap(rtg)->i_ino); + xchk_ip_xref_set_corrupt(sc, rtg_rmap(rtg)); return; } @@ -295,5 +295,5 @@ xchk_xref_is_used_rt_space( if (!xchk_should_check_xref(sc, &error, NULL)) return; if (is_free) - xchk_ino_xref_set_corrupt(sc, rtg_bitmap(rtg)->i_ino); + xchk_ip_xref_set_corrupt(sc, rtg_bitmap(rtg)); } diff --git a/fs/xfs/scrub/rtbitmap_repair.c b/fs/xfs/scrub/rtbitmap_repair.c index f4ca86a2ea1b..dc64902d6c25 100644 --- a/fs/xfs/scrub/rtbitmap_repair.c +++ b/fs/xfs/scrub/rtbitmap_repair.c @@ -382,7 +382,7 @@ xrep_rtbitmap_prep_buf( struct xfs_rtbuf_blkinfo *hdr = bp->b_addr; hdr->rt_magic = cpu_to_be32(XFS_RTBITMAP_MAGIC); - hdr->rt_owner = cpu_to_be64(sc->ip->i_ino); + hdr->rt_owner = cpu_to_be64(I_INO(sc->ip)); hdr->rt_blkno = cpu_to_be64(xfs_buf_daddr(bp)); hdr->rt_lsn = 0; uuid_copy(&hdr->rt_uuid, &sc->mp->m_sb.sb_meta_uuid); diff --git a/fs/xfs/scrub/rtrefcount.c b/fs/xfs/scrub/rtrefcount.c index 4951cc271788..0d10ce2910c2 100644 --- a/fs/xfs/scrub/rtrefcount.c +++ b/fs/xfs/scrub/rtrefcount.c @@ -555,7 +555,7 @@ xchk_rtrefcountbt( if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) return error; - xfs_rmap_ino_bmbt_owner(&btree_oinfo, rtg_refcount(sc->sr.rtg)->i_ino, + xfs_rmap_inode_bmbt_owner(&btree_oinfo, rtg_refcount(sc->sr.rtg), XFS_DATA_FORK); error = xchk_btree(sc, sc->sr.refc_cur, xchk_rtrefcountbt_rec, &btree_oinfo, &rrc); diff --git a/fs/xfs/scrub/rtrefcount_repair.c b/fs/xfs/scrub/rtrefcount_repair.c index f165fb397647..2b939960c7dd 100644 --- a/fs/xfs/scrub/rtrefcount_repair.c +++ b/fs/xfs/scrub/rtrefcount_repair.c @@ -360,7 +360,7 @@ xrep_rtrefc_walk_rmap( return error; /* Skip extents which are not owned by this inode and fork. */ - if (rec->rm_owner != rr->sc->ip->i_ino) + if (rec->rm_owner != I_INO(rr->sc->ip)) return 0; error = xrep_check_ino_btree_mapping(rr->sc, rec); diff --git a/fs/xfs/scrub/rtrmap.c b/fs/xfs/scrub/rtrmap.c index 8b1a8389d32f..043be93c7148 100644 --- a/fs/xfs/scrub/rtrmap.c +++ b/fs/xfs/scrub/rtrmap.c @@ -244,7 +244,6 @@ int xchk_rtrmapbt( struct xfs_scrub *sc) { - struct xfs_inode *ip = rtg_rmap(sc->sr.rtg); struct xfs_owner_info oinfo; struct xchk_rtrmap cr = { }; int error; @@ -253,7 +252,7 @@ xchk_rtrmapbt( if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) return error; - xfs_rmap_ino_bmbt_owner(&oinfo, ip->i_ino, XFS_DATA_FORK); + xfs_rmap_inode_bmbt_owner(&oinfo, rtg_rmap(sc->sr.rtg), XFS_DATA_FORK); return xchk_btree(sc, sc->sr.rmap_cur, xchk_rtrmapbt_rec, &oinfo, &cr); } diff --git a/fs/xfs/scrub/rtrmap_repair.c b/fs/xfs/scrub/rtrmap_repair.c index f2d16ca8d251..a2b72e61edf5 100644 --- a/fs/xfs/scrub/rtrmap_repair.c +++ b/fs/xfs/scrub/rtrmap_repair.c @@ -324,7 +324,7 @@ xrep_rtrmap_scan_dfork( struct xfs_inode *ip) { struct xrep_rtrmap_ifork rf = { - .accum = { .rm_owner = ip->i_ino, }, + .accum = { .rm_owner = I_INO(ip), }, .rr = rr, }; struct xfs_ifork *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK); @@ -392,7 +392,7 @@ xrep_rtrmap_walk_rmap( return error; /* Skip extents which are not owned by this inode and fork. */ - if (rec->rm_owner != rr->sc->ip->i_ino) + if (rec->rm_owner != I_INO(rr->sc->ip)) return 0; error = xrep_check_ino_btree_mapping(rr->sc, rec); diff --git a/fs/xfs/scrub/rtsummary.c b/fs/xfs/scrub/rtsummary.c index efce39d7a1ef..78f72a046887 100644 --- a/fs/xfs/scrub/rtsummary.c +++ b/fs/xfs/scrub/rtsummary.c @@ -189,7 +189,7 @@ xchk_rtsum_record_free( rtlen = xfs_rtxlen_to_extlen(mp, rec->ar_extcount); if (!xfs_verify_rtbext(mp, rtbno, rtlen)) { - xchk_ino_xref_set_corrupt(sc, rtg_bitmap(rtg)->i_ino); + xchk_ip_xref_set_corrupt(sc, rtg_bitmap(rtg)); return -EFSCORRUPTED; } @@ -314,25 +314,25 @@ xchk_rtsummary( /* Is sb_rextents correct? */ if (mp->m_sb.sb_rextents != rts->rextents) { - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } /* Is m_rsumlevels correct? */ if (mp->m_rsumlevels != rts->rsumlevels) { - xchk_ino_set_corrupt(sc, rsumip->i_ino); + xchk_ip_set_corrupt(sc, rsumip); return 0; } /* Is m_rsumsize correct? */ if (mp->m_rsumblocks != rts->rsumblocks) { - xchk_ino_set_corrupt(sc, rsumip->i_ino); + xchk_ip_set_corrupt(sc, rsumip); return 0; } /* The summary file length must be aligned to an fsblock. */ if (rsumip->i_disk_size & mp->m_blockmask) { - xchk_ino_set_corrupt(sc, rsumip->i_ino); + xchk_ip_set_corrupt(sc, rsumip); return 0; } @@ -342,7 +342,7 @@ xchk_rtsummary( * the file can be larger than rsumsize. */ if (rsumip->i_disk_size < XFS_FSB_TO_B(mp, rts->rsumblocks)) { - xchk_ino_set_corrupt(sc, rsumip->i_ino); + xchk_ip_set_corrupt(sc, rsumip); return 0; } @@ -358,7 +358,7 @@ xchk_rtsummary( * EFSCORRUPTED means the rtbitmap is corrupt, which is an xref * error since we're checking the summary file. */ - xchk_ino_set_corrupt(sc, rbmip->i_ino); + xchk_ip_set_corrupt(sc, rbmip); return 0; } if (error) diff --git a/fs/xfs/scrub/rtsummary_repair.c b/fs/xfs/scrub/rtsummary_repair.c index afffbd6e0ad1..f065c3e51ce2 100644 --- a/fs/xfs/scrub/rtsummary_repair.c +++ b/fs/xfs/scrub/rtsummary_repair.c @@ -91,7 +91,7 @@ xrep_rtsummary_prep_buf( struct xfs_rtbuf_blkinfo *hdr = bp->b_addr; hdr->rt_magic = cpu_to_be32(XFS_RTSUMMARY_MAGIC); - hdr->rt_owner = cpu_to_be64(sc->ip->i_ino); + hdr->rt_owner = cpu_to_be64(I_INO(sc->ip)); hdr->rt_blkno = cpu_to_be64(xfs_buf_daddr(bp)); hdr->rt_lsn = 0; uuid_copy(&hdr->rt_uuid, &sc->mp->m_sb.sb_meta_uuid); diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c index 27511a125b39..8742445c86f4 100644 --- a/fs/xfs/scrub/scrub.c +++ b/fs/xfs/scrub/scrub.c @@ -955,7 +955,7 @@ xfs_ioc_scrubv_metadata( * because each scrubber gets to decide its own strategy and return * values for getting an inode. */ - if (head.svh_ino && head.svh_ino != ip_in->i_ino) + if (head.svh_ino && head.svh_ino != I_INO(ip_in)) handle_ip = xchk_scrubv_open_by_handle(mp, &head); /* Run all the scrubbers. */ diff --git a/fs/xfs/scrub/symlink_repair.c b/fs/xfs/scrub/symlink_repair.c index 25416dfb5189..91c86ea0e0f1 100644 --- a/fs/xfs/scrub/symlink_repair.c +++ b/fs/xfs/scrub/symlink_repair.c @@ -144,7 +144,7 @@ xrep_symlink_salvage_remote( fa = bp->b_ops->verify_struct(bp); dsl = bp->b_addr; magic_ok = dsl->sl_magic == cpu_to_be32(XFS_SYMLINK_MAGIC); - hdr_ok = xfs_symlink_hdr_ok(ip->i_ino, offset, byte_cnt, bp); + hdr_ok = xfs_symlink_hdr_ok(I_INO(ip), offset, byte_cnt, bp); if (!hdr_ok || (fa != NULL && !magic_ok)) break; @@ -259,7 +259,7 @@ xrep_symlink_local_to_remote( if (!xfs_has_crc(sc->mp)) return; - dsl->sl_owner = cpu_to_be64(sc->ip->i_ino); + dsl->sl_owner = cpu_to_be64(I_INO(sc->ip)); xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsymlink_hdr) + ifp->if_bytes - 1); } @@ -375,7 +375,7 @@ xrep_symlink_reset_fork( /* Reset the temp symlink target to dummy content. */ xfs_idestroy_fork(ifp); - return xfs_symlink_write_target(sc->tp, sc->tempip, sc->tempip->i_ino, + return xfs_symlink_write_target(sc->tp, sc->tempip, I_INO(sc->tempip), "?", 1, 0, 0); } @@ -434,7 +434,7 @@ xrep_symlink_rebuild( sc->tempip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; /* Write the salvaged target to the temporary link. */ - error = xfs_symlink_write_target(sc->tp, sc->tempip, sc->ip->i_ino, + error = xfs_symlink_write_target(sc->tp, sc->tempip, I_INO(sc->ip), target_buf, target_len, fs_blocks, resblks); if (error) return error; diff --git a/fs/xfs/scrub/tempfile.c b/fs/xfs/scrub/tempfile.c index 8d754df72aa5..e0c630f888cf 100644 --- a/fs/xfs/scrub/tempfile.c +++ b/fs/xfs/scrub/tempfile.c @@ -121,7 +121,7 @@ xrep_tempfile_create( * remote target block, so the owner is irrelevant. */ error = xfs_symlink_write_target(tp, sc->tempip, - sc->tempip->i_ino, ".", 1, 0, 0); + I_INO(sc->tempip), ".", 1, 0, 0); if (error) goto out_trans_cancel; } diff --git a/fs/xfs/scrub/trace.c b/fs/xfs/scrub/trace.c index 70d353287993..e5efc680651f 100644 --- a/fs/xfs/scrub/trace.c +++ b/fs/xfs/scrub/trace.c @@ -48,7 +48,7 @@ xchk_btree_cur_fsbno( if (level == cur->bc_nlevels - 1 && cur->bc_ops->type == XFS_BTREE_TYPE_INODE) - return XFS_INO_TO_FSB(cur->bc_mp, cur->bc_ino.ip->i_ino); + return XFS_INODE_TO_FSB(cur->bc_ino.ip); return NULLFSBLOCK; } diff --git a/fs/xfs/scrub/trace.h b/fs/xfs/scrub/trace.h index 286c5f5e0544..1b7d9e07a27d 100644 --- a/fs/xfs/scrub/trace.h +++ b/fs/xfs/scrub/trace.h @@ -162,7 +162,7 @@ DECLARE_EVENT_CLASS(xchk_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->type = sm->sm_type; __entry->agno = sm->sm_agno; __entry->inum = sm->sm_ino; @@ -236,7 +236,7 @@ DECLARE_EVENT_CLASS(xchk_vector_head_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->agno = vhead->svh_agno; __entry->inum = vhead->svh_ino; __entry->gen = vhead->svh_gen; @@ -340,7 +340,7 @@ TRACE_EVENT(xchk_file_op_error, ), TP_fast_assign( __entry->dev = sc->ip->i_mount->m_super->s_dev; - __entry->ino = sc->ip->i_ino; + __entry->ino = I_INO(sc->ip); __entry->whichfork = whichfork; __entry->type = sc->sm->sm_type; __entry->offset = offset; @@ -438,7 +438,7 @@ DECLARE_EVENT_CLASS(xchk_fblock_error_class, ), TP_fast_assign( __entry->dev = sc->ip->i_mount->m_super->s_dev; - __entry->ino = sc->ip->i_ino; + __entry->ino = I_INO(sc->ip); __entry->whichfork = whichfork; __entry->type = sc->sm->sm_type; __entry->offset = offset; @@ -481,7 +481,7 @@ DECLARE_EVENT_CLASS(xchk_dqiter_class, TP_fast_assign( __entry->dev = cursor->sc->mp->m_super->s_dev; __entry->dqtype = cursor->dqtype; - __entry->ino = cursor->quota_ip->i_ino; + __entry->ino = I_INO(cursor->quota_ip); __entry->cur_id = cursor->id; __entry->startoff = cursor->bmap.br_startoff; __entry->startblock = cursor->bmap.br_startblock; @@ -613,7 +613,7 @@ TRACE_EVENT(xchk_ifork_btree_op_error, TP_fast_assign( xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level); __entry->dev = sc->mp->m_super->s_dev; - __entry->ino = cur->bc_ino.ip->i_ino; + __entry->ino = I_INO(cur->bc_ino.ip); __entry->whichfork = cur->bc_ino.whichfork; __entry->type = sc->sm->sm_type; __assign_str(name); @@ -693,7 +693,7 @@ TRACE_EVENT(xchk_ifork_btree_error, TP_fast_assign( xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level); __entry->dev = sc->mp->m_super->s_dev; - __entry->ino = sc->ip->i_ino; + __entry->ino = I_INO(sc->ip); __entry->whichfork = cur->bc_ino.whichfork; __entry->type = sc->sm->sm_type; __assign_str(name); @@ -785,17 +785,17 @@ TRACE_EVENT(xchk_xref_error, TRACE_EVENT(xchk_iallocbt_check_cluster, TP_PROTO(const struct xfs_perag *pag, xfs_agino_t startino, - xfs_daddr_t map_daddr, unsigned short map_len, + xfs_agblock_t map_agblock, unsigned short map_len, unsigned int chunk_ino, unsigned int nr_inodes, uint16_t cluster_mask, uint16_t holemask, unsigned int cluster_ino), - TP_ARGS(pag, startino, map_daddr, map_len, chunk_ino, nr_inodes, + TP_ARGS(pag, startino, map_agblock, map_len, chunk_ino, nr_inodes, cluster_mask, holemask, cluster_ino), TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_agnumber_t, agno) __field(xfs_agino_t, startino) - __field(xfs_daddr_t, map_daddr) + __field(xfs_agblock_t, map_agblock) __field(unsigned short, map_len) __field(unsigned int, chunk_ino) __field(unsigned int, nr_inodes) @@ -807,7 +807,7 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->dev = pag_mount(pag)->m_super->s_dev; __entry->agno = pag_agno(pag); __entry->startino = startino; - __entry->map_daddr = map_daddr; + __entry->map_agblock = map_agblock; __entry->map_len = map_len; __entry->chunk_ino = chunk_ino; __entry->nr_inodes = nr_inodes; @@ -815,11 +815,11 @@ TRACE_EVENT(xchk_iallocbt_check_cluster, __entry->holemask = holemask; __entry->cluster_ino = cluster_ino; ), - TP_printk("dev %d:%d agno 0x%x startino 0x%x daddr 0x%llx bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", + TP_printk("dev %d:%d agno 0x%x startino 0x%x agblock 0x%x bbcount 0x%x chunkino 0x%x nr_inodes %u cluster_mask 0x%x holemask 0x%x cluster_ino 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->agno, __entry->startino, - __entry->map_daddr, + __entry->map_agblock, __entry->map_len, __entry->chunk_ino, __entry->nr_inodes, @@ -839,7 +839,7 @@ TRACE_EVENT(xchk_inode_is_allocated, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->iflags = ip->i_flags; __entry->mode = VFS_I(ip)->i_mode; ), @@ -1437,7 +1437,7 @@ TRACE_EVENT(xchk_nlinks_collect_dirent, ), TP_fast_assign( __entry->dev = mp->m_super->s_dev; - __entry->dir = dp->i_ino; + __entry->dir = I_INO(dp); __entry->ino = ino; __entry->namelen = name->len; memcpy(__get_str(name), name->name, name->len); @@ -1464,7 +1464,7 @@ TRACE_EVENT(xchk_nlinks_collect_pptr, ), TP_fast_assign( __entry->dev = mp->m_super->s_dev; - __entry->dir = dp->i_ino; + __entry->dir = I_INO(dp); __entry->ino = be64_to_cpu(pptr->p_ino); __entry->namelen = name->len; memcpy(__get_str(name), name->name, name->len); @@ -1509,7 +1509,7 @@ TRACE_EVENT(xchk_nlinks_live_update, ), TP_fast_assign( __entry->dev = mp->m_super->s_dev; - __entry->dir = dp ? dp->i_ino : NULLFSINO; + __entry->dir = dp ? I_INO(dp) : NULLFSINO; __entry->action = action; __entry->ino = ino; __entry->delta = delta; @@ -1602,7 +1602,7 @@ DECLARE_EVENT_CLASS(xchk_nlinks_diff_class, ), TP_fast_assign( __entry->dev = mp->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->ftype = xfs_mode_to_ftype(VFS_I(ip)->i_mode); __entry->nlink = VFS_I(ip)->i_nlink; __entry->parents = live->parents; @@ -1638,7 +1638,7 @@ DECLARE_EVENT_CLASS(xchk_pptr_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->namelen = name->len; memcpy(__get_str(name), name, name->len); __entry->far_ino = far_ino; @@ -1680,7 +1680,7 @@ DECLARE_EVENT_CLASS(xchk_dirtree_class, TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; __entry->path_nr = path_nr; - __entry->child_ino = ip->i_ino; + __entry->child_ino = I_INO(ip); __entry->child_gen = VFS_I(ip)->i_generation; __entry->parent_ino = be64_to_cpu(pptr->p_ino); __entry->parent_gen = be32_to_cpu(pptr->p_gen); @@ -1727,7 +1727,7 @@ DECLARE_EVENT_CLASS(xchk_dirpath_class, __entry->dev = sc->mp->m_super->s_dev; __entry->path_nr = path_nr; __entry->step_nr = step_nr; - __entry->child_ino = ip->i_ino; + __entry->child_ino = I_INO(ip); __entry->child_gen = VFS_I(ip)->i_generation; __entry->parent_ino = be64_to_cpu(pptr->p_ino); __entry->parent_gen = be32_to_cpu(pptr->p_gen); @@ -1830,7 +1830,7 @@ DECLARE_EVENT_CLASS(xchk_dirtree_evaluate_class, ), TP_fast_assign( __entry->dev = dl->sc->mp->m_super->s_dev; - __entry->ino = dl->sc->ip->i_ino; + __entry->ino = I_INO(dl->sc->ip); __entry->rootino = dl->root_ino; __entry->nr_paths = dl->nr_paths; __entry->bad = oc->bad; @@ -1873,8 +1873,8 @@ TRACE_EVENT(xchk_dirpath_changed, __entry->dev = sc->mp->m_super->s_dev; __entry->path_nr = path_nr; __entry->step_nr = step_nr; - __entry->child_ino = ip->i_ino; - __entry->parent_ino = dp->i_ino; + __entry->child_ino = I_INO(ip); + __entry->parent_ino = I_INO(dp); __entry->namelen = xname->len; memcpy(__get_str(name), xname->name, xname->len); ), @@ -1904,9 +1904,9 @@ TRACE_EVENT(xchk_dirtree_live_update, ), TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; - __entry->parent_ino = dp->i_ino; + __entry->parent_ino = I_INO(dp); __entry->action = action; - __entry->child_ino = ip->i_ino; + __entry->child_ino = I_INO(ip); __entry->delta = delta; __entry->namelen = xname->len; memcpy(__get_str(name), xname->name, xname->len); @@ -1933,8 +1933,8 @@ DECLARE_EVENT_CLASS(xchk_metapath_class, ), TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; - __entry->scrub_ino = sc->ip ? sc->ip->i_ino : NULLFSINO; - __entry->parent_ino = dp ? dp->i_ino : NULLFSINO; + __entry->scrub_ino = sc->ip ? I_INO(sc->ip) : NULLFSINO; + __entry->parent_ino = dp ? I_INO(dp) : NULLFSINO; __entry->ino = ino; __assign_str(name); ), @@ -2208,7 +2208,7 @@ TRACE_EVENT(xrep_bmap_found, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->whichfork = whichfork; __entry->lblk = irec->br_startoff; __entry->len = irec->br_blockcount; @@ -2609,7 +2609,7 @@ TRACE_EVENT(xrep_dinode_findmode_dirent, TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; __entry->ino = sc->sm->sm_ino; - __entry->parent_ino = dp->i_ino; + __entry->parent_ino = I_INO(dp); __entry->ftype = ftype; ), TP_printk("dev %d:%d ino 0x%llx parent_ino 0x%llx ftype '%s'", @@ -2633,7 +2633,7 @@ TRACE_EVENT(xrep_dinode_findmode_dirent_inval, TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; __entry->ino = sc->sm->sm_ino; - __entry->parent_ino = dp->i_ino; + __entry->parent_ino = I_INO(dp); __entry->ftype = ftype; __entry->found_ftype = found_ftype; ), @@ -2658,7 +2658,7 @@ TRACE_EVENT(xrep_cow_mark_file_range, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->startoff = startoff; __entry->startblock = startblock; __entry->blockcount = blockcount; @@ -2687,7 +2687,7 @@ TRACE_EVENT(xrep_cow_replace_mapping, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->startoff = irec->br_startoff; __entry->startblock = irec->br_startblock; __entry->blockcount = irec->br_blockcount; @@ -2817,13 +2817,13 @@ TRACE_EVENT(xrep_tempfile_create, ), TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; - __entry->ino = sc->file ? XFS_I(file_inode(sc->file))->i_ino : 0; + __entry->ino = sc->file ? file_inode(sc->file)->i_ino : 0; __entry->type = sc->sm->sm_type; __entry->agno = sc->sm->sm_agno; __entry->inum = sc->sm->sm_ino; __entry->gen = sc->sm->sm_gen; __entry->flags = sc->sm->sm_flags; - __entry->temp_inum = sc->tempip->i_ino; + __entry->temp_inum = I_INO(sc->tempip); ), TP_printk("dev %d:%d ino 0x%llx type %s inum 0x%llx gen 0x%x flags 0x%x temp_inum 0x%llx", MAJOR(__entry->dev), MINOR(__entry->dev), @@ -2850,7 +2850,7 @@ DECLARE_EVENT_CLASS(xrep_tempfile_class, ), TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; - __entry->ino = sc->tempip->i_ino; + __entry->ino = I_INO(sc->tempip); __entry->whichfork = whichfork; __entry->lblk = irec->br_startoff; __entry->len = irec->br_blockcount; @@ -2890,7 +2890,7 @@ TRACE_EVENT(xreap_ifork_extent, ), TP_fast_assign( __entry->dev = sc->mp->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->whichfork = whichfork; __entry->fileoff = irec->br_startoff; __entry->len = irec->br_blockcount; @@ -2946,7 +2946,7 @@ TRACE_EVENT(xrep_xattr_recover_leafblock, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->dabno = dabno; __entry->magic = magic; ), @@ -2971,7 +2971,7 @@ DECLARE_EVENT_CLASS(xrep_xattr_salvage_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->flags = flags; __entry->namelen = namelen; memcpy(__get_str(name), name, namelen); @@ -3011,7 +3011,7 @@ DECLARE_EVENT_CLASS(xrep_pptr_salvage_class, const struct xfs_parent_rec *rec = value; __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->parent_ino = be64_to_cpu(rec->p_ino); __entry->parent_gen = be32_to_cpu(rec->p_gen); __entry->namelen = namelen; @@ -3043,8 +3043,8 @@ DECLARE_EVENT_CLASS(xrep_xattr_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; - __entry->src_ino = arg_ip->i_ino; + __entry->ino = I_INO(ip); + __entry->src_ino = I_INO(arg_ip); ), TP_printk("dev %d:%d ino 0x%llx src 0x%llx", MAJOR(__entry->dev), MINOR(__entry->dev), @@ -3073,8 +3073,8 @@ DECLARE_EVENT_CLASS(xrep_xattr_pptr_scan_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; - __entry->parent_ino = dp->i_ino; + __entry->ino = I_INO(ip); + __entry->parent_ino = I_INO(dp); __entry->parent_gen = VFS_IC(dp)->i_generation; __entry->namelen = name->len; memcpy(__get_str(name), name->name, name->len); @@ -3108,7 +3108,7 @@ TRACE_EVENT(xrep_dir_recover_dirblock, ), TP_fast_assign( __entry->dev = dp->i_mount->m_super->s_dev; - __entry->dir_ino = dp->i_ino; + __entry->dir_ino = I_INO(dp); __entry->dabno = dabno; __entry->magic = magic; __entry->magic_guess = magic_guess; @@ -3131,7 +3131,7 @@ DECLARE_EVENT_CLASS(xrep_dir_class, ), TP_fast_assign( __entry->dev = dp->i_mount->m_super->s_dev; - __entry->dir_ino = dp->i_ino; + __entry->dir_ino = I_INO(dp); __entry->parent_ino = parent_ino; ), TP_printk("dev %d:%d dir 0x%llx parent 0x%llx", @@ -3161,7 +3161,7 @@ DECLARE_EVENT_CLASS(xrep_dirent_class, ), TP_fast_assign( __entry->dev = dp->i_mount->m_super->s_dev; - __entry->dir_ino = dp->i_ino; + __entry->dir_ino = I_INO(dp); __entry->namelen = name->len; memcpy(__get_str(name), name->name, name->len); __entry->ino = ino; @@ -3198,8 +3198,8 @@ DECLARE_EVENT_CLASS(xrep_adoption_class, ), TP_fast_assign( __entry->dev = dp->i_mount->m_super->s_dev; - __entry->dir_ino = dp->i_ino; - __entry->child_ino = ip->i_ino; + __entry->dir_ino = I_INO(dp); + __entry->child_ino = I_INO(ip); __entry->moved = moved; ), TP_printk("dev %d:%d dir 0x%llx child 0x%llx moved? %d", @@ -3224,7 +3224,7 @@ DECLARE_EVENT_CLASS(xrep_parent_salvage_class, ), TP_fast_assign( __entry->dev = dp->i_mount->m_super->s_dev; - __entry->dir_ino = dp->i_ino; + __entry->dir_ino = I_INO(dp); __entry->ino = ino; ), TP_printk("dev %d:%d dir 0x%llx parent 0x%llx", @@ -3254,7 +3254,7 @@ DECLARE_EVENT_CLASS(xrep_pptr_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->parent_ino = be64_to_cpu(pptr->p_ino); __entry->parent_gen = be32_to_cpu(pptr->p_gen); __entry->namelen = name->len; @@ -3292,8 +3292,8 @@ DECLARE_EVENT_CLASS(xrep_pptr_scan_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; - __entry->parent_ino = dp->i_ino; + __entry->ino = I_INO(ip); + __entry->parent_ino = I_INO(dp); __entry->parent_gen = VFS_IC(dp)->i_generation; __entry->namelen = name->len; memcpy(__get_str(name), name->name, name->len); @@ -3392,7 +3392,7 @@ TRACE_EVENT(xrep_symlink_salvage_target, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->targetlen = targetlen; memcpy(__get_str(target), target, targetlen); __get_str(target)[targetlen] = 0; @@ -3413,7 +3413,7 @@ DECLARE_EVENT_CLASS(xrep_symlink_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); ), TP_printk("dev %d:%d ip 0x%llx", MAJOR(__entry->dev), MINOR(__entry->dev), @@ -3443,7 +3443,7 @@ TRACE_EVENT(xrep_iunlink_visit, TP_fast_assign( __entry->dev = pag_mount(pag)->m_super->s_dev; __entry->agno = pag_agno(pag); - __entry->agino = XFS_INO_TO_AGINO(pag_mount(pag), ip->i_ino); + __entry->agino = XFS_INODE_TO_AGINO(ip); __entry->bucket = bucket; __entry->bucket_agino = bucket_agino; __entry->prev_agino = ip->i_prev_unlinked; @@ -3473,8 +3473,8 @@ TRACE_EVENT(xrep_iunlink_reload_next, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(ip); + __entry->agino = XFS_INODE_TO_AGINO(ip); __entry->old_prev_agino = ip->i_prev_unlinked; __entry->prev_agino = prev_agino; __entry->next_agino = ip->i_next_unlinked; @@ -3503,8 +3503,8 @@ TRACE_EVENT(xrep_iunlink_reload_ondisk, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(ip); + __entry->agino = XFS_INODE_TO_AGINO(ip); __entry->nlink = VFS_I(ip)->i_nlink; __entry->next_agino = ip->i_next_unlinked; ), @@ -3590,8 +3590,8 @@ TRACE_EVENT(xrep_iunlink_relink_next, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(ip); + __entry->agino = XFS_INODE_TO_AGINO(ip); __entry->next_agino = ip->i_next_unlinked; __entry->new_next_agino = next_agino; ), @@ -3616,8 +3616,8 @@ TRACE_EVENT(xrep_iunlink_relink_prev, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(ip); + __entry->agino = XFS_INODE_TO_AGINO(ip); __entry->prev_agino = ip->i_prev_unlinked; __entry->new_prev_agino = prev_agino; ), diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index f279055fcea0..2a0c54256e93 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -139,6 +139,17 @@ xfs_end_ioend_write( */ error = blk_status_to_errno(ioend->io_bio.bi_status); if (unlikely(error)) { + /* + * Zoned writes update the in-core open zone accounting before + * I/O submission. A failed write leaves that state + * inconsistent, so shut down the filesystem instead of letting + * later writers wait forever for open zone space to become + * available. + */ + if (is_zoned) { + xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); + goto done; + } if (ioend->io_flags & IOMAP_IOEND_SHARED) { ASSERT(!is_zoned); xfs_reflink_cancel_cow_range(ip, offset, size, true); @@ -268,7 +279,7 @@ xfs_discard_folio( xfs_alert_ratelimited(mp, "page discard on page "PTR_FMT", inode 0x%llx, pos %llu.", - folio, ip->i_ino, pos); + folio, I_INO(ip), pos); /* * The end of the punch range is always the offset of the first diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index deab14f31b38..a53ee2b0c54a 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -378,7 +378,7 @@ xfs_attr_log_item( * structure with fields from this xfs_attr_intent */ attrp = &attrip->attri_format; - attrp->alfi_ino = args->dp->i_ino; + attrp->alfi_ino = I_INO(args->dp); ASSERT(!(attr->xattri_op_flags & ~XFS_ATTRI_OP_FLAGS_TYPE_MASK)); attrp->alfi_op_flags = attr->xattri_op_flags; attrp->alfi_value_len = nv->value.iov_len; @@ -695,7 +695,7 @@ xfs_attri_recover_work( args->attr_filter = attrp->alfi_attr_filter & XFS_ATTRI_FILTER_MASK; args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT | XFS_DA_OP_LOGGED; - args->owner = args->dp->i_ino; + args->owner = I_INO(args->dp); xfs_attr_sethash(args); switch (xfs_attr_intent_op(attr)) { diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 114566b1ae5c..f751edb930b6 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -248,7 +248,7 @@ xfs_attr_node_list_lookup( goto out_corruptbuf; } - fa = xfs_da3_node_header_check(bp, dp->i_ino); + fa = xfs_da3_node_header_check(bp, I_INO(dp)); if (fa) goto out_corruptbuf; @@ -287,7 +287,7 @@ xfs_attr_node_list_lookup( } } - fa = xfs_attr3_leaf_header_check(bp, dp->i_ino); + fa = xfs_attr3_leaf_header_check(bp, I_INO(dp)); if (fa) { __xfs_buf_mark_corrupt(bp, fa); goto out_releasebuf; @@ -348,7 +348,7 @@ xfs_attr_node_list( case XFS_DA_NODE_MAGIC: case XFS_DA3_NODE_MAGIC: trace_xfs_attr_list_wrong_blk(context); - fa = xfs_da3_node_header_check(bp, dp->i_ino); + fa = xfs_da3_node_header_check(bp, I_INO(dp)); if (fa) { __xfs_buf_mark_corrupt(bp, fa); xfs_dirattr_mark_sick(dp, XFS_ATTR_FORK); @@ -359,7 +359,7 @@ xfs_attr_node_list( case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR3_LEAF_MAGIC: leaf = bp->b_addr; - fa = xfs_attr3_leaf_header_check(bp, dp->i_ino); + fa = xfs_attr3_leaf_header_check(bp, I_INO(dp)); if (fa) { __xfs_buf_mark_corrupt(bp, fa); xfs_trans_brelse(context->tp, bp); @@ -417,7 +417,7 @@ xfs_attr_node_list( break; cursor->blkno = leafhdr.forw; xfs_trans_brelse(context->tp, bp); - error = xfs_attr3_leaf_read(context->tp, dp, dp->i_ino, + error = xfs_attr3_leaf_read(context->tp, dp, I_INO(dp), cursor->blkno, &bp); if (error) return error; @@ -543,7 +543,7 @@ xfs_attr_leaf_list( context->cursor.blkno = 0; error = xfs_attr3_leaf_read(context->tp, context->dp, - context->dp->i_ino, 0, &bp); + I_INO(context->dp), 0, &bp); if (error) return error; diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index b237a25d6045..89f6e79a955f 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -245,7 +245,7 @@ xfs_bmap_update_diff_items( struct xfs_bmap_intent *ba = bi_entry(a); struct xfs_bmap_intent *bb = bi_entry(b); - return cmp_int(ba->bi_owner->i_ino, bb->bi_owner->i_ino); + return cmp_int(I_INO(ba->bi_owner), I_INO(bb->bi_owner)); } /* Log bmap updates in the intent item. */ @@ -266,7 +266,7 @@ xfs_bmap_update_log_item( next_extent = atomic_inc_return(&buip->bui_next_extent) - 1; ASSERT(next_extent < buip->bui_format.bui_nextents); map = &buip->bui_format.bui_extents[next_extent]; - map->me_owner = bi->bi_owner->i_ino; + map->me_owner = I_INO(bi->bi_owner); map->me_startblock = bi->bi_bmap.br_startblock; map->me_startoff = bi->bi_bmap.br_startoff; map->me_len = bi->bi_bmap.br_blockcount; diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 0ab00615f1ad..3b9f262f8e91 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1479,7 +1479,7 @@ xfs_swap_change_owner( struct xfs_trans *tp = *tpp; do { - error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK, ip->i_ino, + error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK, I_INO(ip), NULL); /* success or fatal error */ if (error != -EAGAIN) @@ -1631,7 +1631,7 @@ xfs_swap_extents( if (error) { xfs_notice(mp, "%s: inode 0x%llx format is incompatible for exchanging.", - __func__, ip->i_ino); + __func__, I_INO(ip)); goto out_trans_cancel; } diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 0cea458f1353..3ce12fe1c307 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -623,7 +623,7 @@ _xfs_buf_read( * type. If repair can't establish that, the buffer will be left in memory * with NULL buffer ops. */ -int +static int xfs_buf_reverify( struct xfs_buf *bp, const struct xfs_buf_ops *ops) diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index bf39d89f0f6d..b3cd1c7029f1 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h @@ -365,7 +365,6 @@ int xfs_configure_buftarg(struct xfs_buftarg *btp, unsigned int sectorsize, #define xfs_readonly_buftarg(buftarg) bdev_read_only((buftarg)->bt_bdev) -int xfs_buf_reverify(struct xfs_buf *bp, const struct xfs_buf_ops *ops); bool xfs_verify_magic(struct xfs_buf *bp, __be32 dmagic); bool xfs_verify_magic16(struct xfs_buf *bp, __be16 dmagic); diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c index 60a80d4173f7..577f7a581043 100644 --- a/fs/xfs/xfs_dir2_readdir.c +++ b/fs/xfs/xfs_dir2_readdir.c @@ -84,7 +84,7 @@ xfs_dir2_sf_getdents( */ if (ctx->pos <= dot_offset) { ctx->pos = dot_offset & 0x7fffffff; - if (!dir_emit(ctx, ".", 1, dp->i_ino, DT_DIR)) + if (!dir_emit(ctx, ".", 1, I_INO(dp), DT_DIR)) return 0; } @@ -532,7 +532,7 @@ xfs_readdir( args.dp = dp; args.geo = dp->i_mount->m_dir_geo; args.trans = tp; - args.owner = dp->i_ino; + args.owner = I_INO(dp); if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL) return xfs_dir2_sf_getdents(&args, ctx); diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 69e9bc588c8b..c311f61d9554 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -1216,6 +1216,14 @@ xfs_qm_dqflush_check( type != XFS_DQTYPE_PROJ) return __this_address; + /* bigtime flag should never be set on root dquots */ + if (dqp->q_type & XFS_DQTYPE_BIGTIME) { + if (!xfs_has_bigtime(dqp->q_mount)) + return __this_address; + if (dqp->q_id == 0) + return __this_address; + } + if (dqp->q_id == 0) return NULL; @@ -1231,14 +1239,6 @@ xfs_qm_dqflush_check( !dqp->q_rtb.timer) return __this_address; - /* bigtime flag should never be set on root dquots */ - if (dqp->q_type & XFS_DQTYPE_BIGTIME) { - if (!xfs_has_bigtime(dqp->q_mount)) - return __this_address; - if (dqp->q_id == 0) - return __this_address; - } - return NULL; } diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index d652240a1dca..9ece70fd94ca 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -369,7 +369,7 @@ xfs_inode_verifier_error( xfs_alert(mp, "Metadata %s detected at %pS, inode 0x%llx %s", error == -EFSBADCRC ? "CRC error" : "corruption", - fa, ip->i_ino, name); + fa, I_INO(ip), name); xfs_alert(mp, "Unmount and run xfs_repair"); diff --git a/fs/xfs/xfs_exchmaps_item.c b/fs/xfs/xfs_exchmaps_item.c index 13a42467370f..c3745d33e54e 100644 --- a/fs/xfs/xfs_exchmaps_item.c +++ b/fs/xfs/xfs_exchmaps_item.c @@ -227,9 +227,9 @@ xfs_exchmaps_create_intent( xmi_lip = xfs_xmi_init(tp->t_mountp); xlf = &xmi_lip->xmi_format; - xlf->xmi_inode1 = xmi->xmi_ip1->i_ino; + xlf->xmi_inode1 = I_INO(xmi->xmi_ip1); xlf->xmi_igen1 = VFS_I(xmi->xmi_ip1)->i_generation; - xlf->xmi_inode2 = xmi->xmi_ip2->i_ino; + xlf->xmi_inode2 = I_INO(xmi->xmi_ip2); xlf->xmi_igen2 = VFS_I(xmi->xmi_ip2)->i_generation; xlf->xmi_startoff1 = xmi->xmi_startoff1; xlf->xmi_startoff2 = xmi->xmi_startoff2; diff --git a/fs/xfs/xfs_exchrange.c b/fs/xfs/xfs_exchrange.c index 5c083f29ea65..94965a6c2187 100644 --- a/fs/xfs/xfs_exchrange.c +++ b/fs/xfs/xfs_exchrange.c @@ -91,7 +91,7 @@ xfs_exchrange_check_freshness( trace_xfs_exchrange_freshness(fxr, ip2); /* Check that file2 hasn't otherwise been modified. */ - if (fxr->file2_ino != ip2->i_ino || + if (fxr->file2_ino != inode2->i_ino || fxr->file2_gen != inode2->i_generation || !timespec64_equal(&fxr->file2_ctime, &ctime) || !timespec64_equal(&fxr->file2_mtime, &mtime)) @@ -863,7 +863,7 @@ xfs_ioc_start_commit( kern_f->file2_ctime_nsec = kstat.ctime.tv_nsec; kern_f->file2_mtime = kstat.mtime.tv_sec; kern_f->file2_mtime_nsec = kstat.mtime.tv_nsec; - kern_f->file2_ino = ip2->i_ino; + kern_f->file2_ino = inode2->i_ino; kern_f->file2_gen = inode2->i_generation; kern_f->magic = XCR_FRESH_MAGIC; xfs_iunlock(ip2, lockflags); diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index 9b2ad3786b19..9afda52ed1a2 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c @@ -82,19 +82,19 @@ xfs_fs_encode_fh( switch (fileid_type) { case FILEID_INO32_GEN_PARENT: - fid->i32.parent_ino = XFS_I(parent)->i_ino; + fid->i32.parent_ino = parent->i_ino; fid->i32.parent_gen = parent->i_generation; fallthrough; case FILEID_INO32_GEN: - fid->i32.ino = XFS_I(inode)->i_ino; + fid->i32.ino = inode->i_ino; fid->i32.gen = inode->i_generation; break; case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: - fid64->parent_ino = XFS_I(parent)->i_ino; + fid64->parent_ino = parent->i_ino; fid64->parent_gen = parent->i_generation; fallthrough; case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: - fid64->ino = XFS_I(inode)->i_ino; + fid64->ino = inode->i_ino; fid64->gen = inode->i_generation; break; } diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c index 32e641d76e92..bb46852075f2 100644 --- a/fs/xfs/xfs_filestream.c +++ b/fs/xfs/xfs_filestream.c @@ -225,7 +225,7 @@ xfs_filestream_lookup_association( atomic_inc(&pag_group(pag)->xg_active_ref); xfs_mru_cache_done(mp->m_filestream); - trace_xfs_filestream_lookup(pag, ap->ip->i_ino); + trace_xfs_filestream_lookup(pag, I_INO(ap->ip)); ap->blkno = xfs_agbno_to_fsb(pag, 0); xfs_bmap_adjacent(ap); @@ -345,7 +345,7 @@ xfs_filestream_select_ag( args->total = ap->total; pip = xfs_filestream_get_parent(ap->ip); if (pip) { - ino = pip->i_ino; + ino = I_INO(pip); error = xfs_filestream_lookup_association(ap, args, ino, longest); xfs_irele(pip); @@ -370,7 +370,7 @@ void xfs_filestream_deassociate( struct xfs_inode *ip) { - xfs_mru_cache_delete(ip->i_mount->m_filestream, ip->i_ino); + xfs_mru_cache_delete(ip->i_mount->m_filestream, I_INO(ip)); } int diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 8d64d904d73c..67624a804a7f 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -124,7 +124,9 @@ xfs_growfs_data_private( mp->m_sb.sb_rextsize); if (error) return error; - xfs_growfs_compute_deltas(mp, nb, &delta, &nagcount); + + nagcount = xfs_growfs_compute_agcount(mp, &nb); + delta = nb - mp->m_sb.sb_dblocks; /* * Reject filesystems with a single AG because they are not diff --git a/fs/xfs/xfs_handle.c b/fs/xfs/xfs_handle.c index 2b8617ae7ec2..0689cade8f74 100644 --- a/fs/xfs/xfs_handle.c +++ b/fs/xfs/xfs_handle.c @@ -124,7 +124,7 @@ xfs_find_handle( if (cmd == XFS_IOC_PATH_TO_FSHANDLE) hsize = xfs_fshandle_init(ip->i_mount, &handle); else - hsize = xfs_filehandle_init(ip->i_mount, ip->i_ino, + hsize = xfs_filehandle_init(ip->i_mount, inode->i_ino, inode->i_generation, &handle); error = -EFAULT; @@ -808,7 +808,7 @@ xfs_getparents( sizeof(struct xfs_attrlist_cursor)); /* Is this the root directory? */ - if (ip->i_ino == mp->m_sb.sb_rootino) + if (I_INO(ip) == mp->m_sb.sb_rootino) gp->gp_oflags |= XFS_GETPARENTS_OFLAG_ROOT; if (gpx->context.seen_enough == 0) { diff --git a/fs/xfs/xfs_healthmon.c b/fs/xfs/xfs_healthmon.c index 26c325d34bd1..4521ffdab9f1 100644 --- a/fs/xfs/xfs_healthmon.c +++ b/fs/xfs/xfs_healthmon.c @@ -533,7 +533,7 @@ xfs_healthmon_report_inode( struct xfs_healthmon_event event = { .type = type, .domain = XFS_HEALTHMON_INODE, - .ino = ip->i_ino, + .ino = I_INO(ip), .gen = VFS_I(ip)->i_generation, }; struct xfs_healthmon *hm = xfs_healthmon_get(ip->i_mount); @@ -646,7 +646,7 @@ xfs_healthmon_report_file_ioerror( struct xfs_healthmon_event event = { .type = file_ioerr_type(p->type), .domain = XFS_HEALTHMON_FILERANGE, - .fino = ip->i_ino, + .fino = I_INO(ip), .fgen = VFS_I(ip)->i_generation, .fpos = p->pos, .flen = p->len, @@ -1182,7 +1182,7 @@ xfs_ioc_health_monitor( */ if (!capable(CAP_SYS_ADMIN)) return -EPERM; - if (ip->i_ino != mp->m_sb.sb_rootino) + if (I_INO(ip) != mp->m_sb.sb_rootino) return -EPERM; if (current_user_ns() != &init_user_ns) return -EPERM; diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 2040a9292ee6..9d8dd30bd927 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -101,6 +101,7 @@ xfs_inode_alloc( return NULL; } + VFS_I(ip)->i_ino = ino; /* VFS doesn't initialise i_mode! */ VFS_I(ip)->i_mode = 0; mapping_set_folio_min_order(VFS_I(ip)->i_mapping, @@ -108,10 +109,8 @@ xfs_inode_alloc( XFS_STATS_INC(mp, xs_inodes_active); ASSERT(atomic_read(&ip->i_pincount) == 0); - ASSERT(ip->i_ino == 0); /* initialise the xfs inode */ - ip->i_ino = ino; ip->i_mount = mp; memset(&ip->i_imap, 0, sizeof(struct xfs_imap)); ip->i_cowfp = NULL; @@ -193,7 +192,7 @@ xfs_inode_free( */ spin_lock(&ip->i_flags_lock); ip->i_flags = XFS_IRECLAIM; - ip->i_ino = 0; + VFS_I(ip)->i_ino = 0; spin_unlock(&ip->i_flags_lock); __xfs_inode_free(ip); @@ -329,6 +328,7 @@ xfs_reinit_inode( struct inode *inode) { int error; + u64 ino = inode->i_ino; uint32_t nlink = inode->i_nlink; uint32_t generation = inode->i_generation; uint64_t version = inode_peek_iversion(inode); @@ -340,6 +340,7 @@ xfs_reinit_inode( error = inode_init_always(mp->m_super, inode); + inode->i_ino = ino; set_nlink(inode, nlink); inode->i_generation = generation; inode_set_iversion_queried(inode, version); @@ -397,7 +398,7 @@ xfs_iget_recycle( */ ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS; ip->i_flags |= XFS_INEW; - xfs_perag_clear_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), + xfs_perag_clear_inode_tag(pag, XFS_INODE_TO_AGINO(ip), XFS_ICI_RECLAIM_TAG); inode_state_assign_raw(inode, I_NEW); spin_unlock(&ip->i_flags_lock); @@ -426,9 +427,8 @@ xfs_iget_check_free_state( if (VFS_I(ip)->i_mode != 0) { xfs_warn(ip->i_mount, "Corruption detected! Free inode 0x%llx not marked free! (mode 0x%x)", - ip->i_ino, VFS_I(ip)->i_mode); - xfs_agno_mark_sick(ip->i_mount, - XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino), + I_INO(ip), VFS_I(ip)->i_mode); + xfs_agno_mark_sick(ip->i_mount, XFS_INODE_TO_AGNO(ip), XFS_SICK_AG_INOBT); return -EFSCORRUPTED; } @@ -436,9 +436,8 @@ xfs_iget_check_free_state( if (ip->i_nblocks != 0) { xfs_warn(ip->i_mount, "Corruption detected! Free inode 0x%llx has blocks allocated!", - ip->i_ino); - xfs_agno_mark_sick(ip->i_mount, - XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino), + I_INO(ip)); + xfs_agno_mark_sick(ip->i_mount, XFS_INODE_TO_AGNO(ip), XFS_SICK_AG_INOBT); return -EFSCORRUPTED; } @@ -516,7 +515,7 @@ xfs_iget_cache_hit( * will not match, so check for that, too. */ spin_lock(&ip->i_flags_lock); - if (ip->i_ino != ino) + if (I_INO(ip) != ino) goto out_skip; /* @@ -646,7 +645,7 @@ xfs_iget_cache_miss( */ xfs_iflags_set(ip, XFS_INEW); - error = xfs_imap(pag, tp, ip->i_ino, &ip->i_imap, flags); + error = xfs_imap(pag, tp, I_INO(ip), &ip->i_imap, flags); if (error) goto out_destroy; @@ -664,7 +663,7 @@ xfs_iget_cache_miss( } else { struct xfs_buf *bp; - error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp); + error = xfs_read_icluster(pag, tp, ip->i_imap.im_agbno, &bp); if (error) goto out_destroy; @@ -819,8 +818,11 @@ xfs_iget( * now. If it's a new inode being created, xfs_init_new_inode will * handle it. */ - if (xfs_iflags_test(ip, XFS_INEW) && VFS_I(ip)->i_mode != 0) - xfs_setup_existing_inode(ip); + if (xfs_iflags_test(ip, XFS_INEW) && VFS_I(ip)->i_mode != 0) { + xfs_setup_inode(ip); + xfs_setup_iops(ip); + xfs_finish_inode_setup(ip); + } return 0; out_error_or_again: @@ -962,7 +964,7 @@ xfs_reclaim_inode( struct xfs_inode *ip, struct xfs_perag *pag) { - xfs_ino_t ino = ip->i_ino; /* for radix_tree_delete */ + xfs_ino_t ino = I_INO(ip); /* for radix_tree_delete */ if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) goto out; @@ -1010,7 +1012,7 @@ xfs_reclaim_inode( */ spin_lock(&ip->i_flags_lock); ip->i_flags = XFS_IRECLAIM; - ip->i_ino = 0; + VFS_I(ip)->i_ino = 0; ip->i_sick = 0; ip->i_checked = 0; spin_unlock(&ip->i_flags_lock); @@ -1287,10 +1289,10 @@ xfs_blockgc_set_iflag( ip->i_flags |= iflag; spin_unlock(&ip->i_flags_lock); - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); spin_lock(&pag->pag_ici_lock); - xfs_perag_set_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), + xfs_perag_set_inode_tag(pag, XFS_INODE_TO_AGINO(ip), XFS_ICI_BLOCKGC_TAG); spin_unlock(&pag->pag_ici_lock); @@ -1324,10 +1326,10 @@ xfs_blockgc_clear_iflag( if (!clear_tag) return; - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); spin_lock(&pag->pag_ici_lock); - xfs_perag_clear_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), + xfs_perag_clear_inode_tag(pag, XFS_INODE_TO_AGINO(ip), XFS_ICI_BLOCKGC_TAG); spin_unlock(&pag->pag_ici_lock); @@ -1510,7 +1512,7 @@ xfs_blockgc_igrab( /* Check for stale RCU freed inode */ spin_lock(&ip->i_flags_lock); - if (!ip->i_ino) + if (!I_INO(ip)) goto out_unlock_noent; if (ip->i_flags & XFS_BLOCKGC_NOGRAB_IFLAGS) @@ -1802,10 +1804,10 @@ xfs_icwalk_ag( * us to see this inode, so another lookup from the * same index will not find it again. */ - if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag_agno(pag)) + if (XFS_INODE_TO_AGNO(ip) != pag_agno(pag)) continue; - first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1); - if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino)) + first_index = XFS_INO_TO_AGINO(mp, I_INO(ip) + 1); + if (first_index < XFS_INODE_TO_AGINO(ip)) done = true; } @@ -1892,7 +1894,7 @@ xfs_check_delalloc( if (isnullstartblock(got.br_startblock)) { xfs_warn(ip->i_mount, "ino %llx %s fork has delalloc extent at [0x%llx:0x%llx]", - ip->i_ino, + I_INO(ip), whichfork == XFS_DATA_FORK ? "data" : "cow", got.br_startoff, got.br_blockcount); } @@ -1916,14 +1918,14 @@ xfs_inodegc_set_reclaimable( ASSERT(0); } - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); spin_lock(&pag->pag_ici_lock); spin_lock(&ip->i_flags_lock); trace_xfs_inode_set_reclaimable(ip); ip->i_flags &= ~(XFS_NEED_INACTIVE | XFS_INACTIVATING); ip->i_flags |= XFS_IRECLAIMABLE; - xfs_perag_set_inode_tag(pag, XFS_INO_TO_AGINO(mp, ip->i_ino), + xfs_perag_set_inode_tag(pag, XFS_INODE_TO_AGINO(ip), XFS_ICI_RECLAIM_TAG); spin_unlock(&ip->i_flags_lock); diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index ddf2707c8894..317eb57f989f 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -495,9 +495,9 @@ xfs_lock_two_inodes( ASSERT(!(ip1_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL))); ASSERT(!(ip0_mode & (XFS_MMAPLOCK_SHARED|XFS_MMAPLOCK_EXCL))); ASSERT(!(ip1_mode & (XFS_MMAPLOCK_SHARED|XFS_MMAPLOCK_EXCL))); - ASSERT(ip0->i_ino != ip1->i_ino); + ASSERT(I_INO(ip0) != I_INO(ip1)); - if (ip0->i_ino > ip1->i_ino) { + if (I_INO(ip0) > I_INO(ip1)) { swap(ip0, ip1); swap(ip0_mode, ip1_mode); } @@ -1357,7 +1357,7 @@ xfs_inactive_health( if (sick & XFS_SICK_INO_FORGET) return; - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); if (!pag) { /* There had better still be a perag structure! */ ASSERT(0); @@ -1380,7 +1380,7 @@ int xfs_inactive( xfs_inode_t *ip) { - struct xfs_mount *mp; + struct xfs_mount *mp = ip->i_mount; int error = 0; int truncate = 0; @@ -1393,7 +1393,20 @@ xfs_inactive( goto out; } - mp = ip->i_mount; + /* + * If the filesystem has been shut down - for example a mount that + * failed after background inactivation was enabled - do not + * inactivate the inode. Inactivation modifies persistent metadata, + * its transactions cannot complete on a shut down mount, and the + * subsystems it relies on (e.g. quota, mp->m_quotainfo) may not be + * set up. The attached dquots are dropped at the out: label and the + * inode then goes straight to reclaim, the same way + * xfs_inode_needs_inactive() already declines to inactivate on a shut + * down mount at queue time. + */ + if (xfs_is_shutdown(mp)) + goto out; + ASSERT(!xfs_iflags_test(ip, XFS_IRECOVERY)); xfs_inactive_health(ip); @@ -1513,7 +1526,7 @@ xfs_iunlink_lookup( * Inode in RCU freeing limbo should not happen. Warn about this and * let the caller handle the failure. */ - if (WARN_ON_ONCE(!ip->i_ino)) { + if (WARN_ON_ONCE(!I_INO(ip))) { rcu_read_unlock(); return NULL; } @@ -1614,7 +1627,7 @@ xfs_ifree_mark_inode_stale( * valid, the wrong inode or stale. */ spin_lock(&ip->i_flags_lock); - if (ip->i_ino != inum || __xfs_iflags_test(ip, XFS_ISTALE)) + if (I_INO(ip) != inum || __xfs_iflags_test(ip, XFS_ISTALE)) goto out_iflags_unlock; /* @@ -1796,7 +1809,7 @@ xfs_ifree( ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode)); ASSERT(ip->i_nblocks == 0); - pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); error = xfs_inode_uninit(tp, pag, ip, &xic); if (error) @@ -2055,7 +2068,7 @@ xfs_sort_inodes( */ for (i = 0; i < num_inodes; i++) { for (j = 1; j < num_inodes; j++) { - if (i_tab[j]->i_ino < i_tab[j-1]->i_ino) + if (I_INO(i_tab[j]) < I_INO(i_tab[j-1])) swap(i_tab[j], i_tab[j - 1]); } } @@ -2305,8 +2318,7 @@ xfs_rename( struct xfs_perag *pag; struct xfs_buf *bp; - pag = xfs_perag_get(mp, - XFS_INO_TO_AGNO(mp, inodes[i]->i_ino)); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(inodes[i])); error = xfs_read_agi(pag, tp, 0, &bp); xfs_perag_put(pag); if (error) @@ -2387,7 +2399,7 @@ xfs_iflush( XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_1)) { xfs_alert_tag(mp, XFS_PTAG_IFLUSH, "%s: Bad inode %llu magic number 0x%x, ptr "PTR_FMT, - __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip); + __func__, I_INO(ip), be16_to_cpu(dip->di_magic), dip); goto flush_out; } if (ip->i_df.if_format == XFS_DINODE_FMT_META_BTREE) { @@ -2396,7 +2408,7 @@ xfs_iflush( xfs_alert_tag(mp, XFS_PTAG_IFLUSH, "%s: Bad %s meta btree inode %Lu, ptr "PTR_FMT, __func__, xfs_metafile_type_str(ip->i_metatype), - ip->i_ino, ip); + I_INO(ip), ip); goto flush_out; } } else if (S_ISREG(VFS_I(ip)->i_mode)) { @@ -2405,7 +2417,7 @@ xfs_iflush( XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_3)) { xfs_alert_tag(mp, XFS_PTAG_IFLUSH, "%s: Bad regular inode %llu, ptr "PTR_FMT, - __func__, ip->i_ino, ip); + __func__, I_INO(ip), ip); goto flush_out; } } else if (S_ISDIR(VFS_I(ip)->i_mode)) { @@ -2415,7 +2427,7 @@ xfs_iflush( XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_4)) { xfs_alert_tag(mp, XFS_PTAG_IFLUSH, "%s: Bad directory inode %llu, ptr "PTR_FMT, - __func__, ip->i_ino, ip); + __func__, I_INO(ip), ip); goto flush_out; } } @@ -2424,7 +2436,7 @@ xfs_iflush( xfs_alert_tag(mp, XFS_PTAG_IFLUSH, "%s: detected corrupt incore inode %llu, " "total extents = %llu nblocks = %lld, ptr "PTR_FMT, - __func__, ip->i_ino, + __func__, I_INO(ip), ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af), ip->i_nblocks, ip); goto flush_out; @@ -2433,7 +2445,7 @@ xfs_iflush( XFS_TEST_ERROR(mp, XFS_ERRTAG_IFLUSH_6)) { xfs_alert_tag(mp, XFS_PTAG_IFLUSH, "%s: bad inode %llu, forkoff 0x%x, ptr "PTR_FMT, - __func__, ip->i_ino, ip->i_forkoff, ip); + __func__, I_INO(ip), ip->i_forkoff, ip); goto flush_out; } @@ -2441,7 +2453,7 @@ xfs_iflush( ip->i_af.if_format == XFS_DINODE_FMT_META_BTREE) { xfs_alert_tag(mp, XFS_PTAG_IFLUSH, "%s: meta btree in inode %Lu attr fork, ptr "PTR_FMT, - __func__, ip->i_ino, ip); + __func__, I_INO(ip), ip); goto flush_out; } @@ -2741,7 +2753,7 @@ xfs_mmaplock_two_inodes_and_break_dax_layout( { int error; - if (ip1->i_ino > ip2->i_ino) + if (I_INO(ip1) > I_INO(ip2)) swap(ip1, ip2); again: @@ -2853,8 +2865,8 @@ xfs_inode_reload_unlinked_bucket( struct xfs_buf *agibp; struct xfs_agi *agi; struct xfs_perag *pag; - xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ip->i_ino); - xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); + xfs_agnumber_t agno = XFS_INODE_TO_AGNO(ip); + xfs_agino_t agino = XFS_INODE_TO_AGINO(ip); xfs_agino_t prev_agino, next_agino; unsigned int bucket; bool foundit = false; diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index bd6d33557194..34c1038ebfcd 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -30,7 +30,6 @@ typedef struct xfs_inode { struct xfs_dquot *i_pdquot; /* project dquot */ /* Inode location stuff */ - xfs_ino_t i_ino; /* inode number (agno/agino)*/ struct xfs_imap i_imap; /* location for xfs_imap() */ /* Extent information. */ @@ -184,6 +183,11 @@ static inline const struct inode *VFS_IC(const struct xfs_inode *ip) return &ip->i_vnode; } +static inline xfs_ino_t I_INO(const struct xfs_inode *ip) +{ + return VFS_IC(ip)->i_ino; +} + /* * For regular files we only update the on-disk filesize when actually * writing data back to disk. Until then only the copy in the VFS inode @@ -299,9 +303,9 @@ static inline bool xfs_is_internal_inode(const struct xfs_inode *ip) * Before metadata directories, the only metadata inodes were the * three quota files, the realtime bitmap, and the realtime summary. */ - return ip->i_ino == mp->m_sb.sb_rbmino || - ip->i_ino == mp->m_sb.sb_rsumino || - xfs_is_quota_inode(&mp->m_sb, ip->i_ino); + return I_INO(ip) == mp->m_sb.sb_rbmino || + I_INO(ip) == mp->m_sb.sb_rsumino || + xfs_is_quota_inode(&mp->m_sb, I_INO(ip)); } static inline bool xfs_is_zoned_inode(const struct xfs_inode *ip) @@ -630,13 +634,6 @@ static inline void xfs_finish_inode_setup(struct xfs_inode *ip) unlock_new_inode(VFS_I(ip)); } -static inline void xfs_setup_existing_inode(struct xfs_inode *ip) -{ - xfs_setup_inode(ip); - xfs_setup_iops(ip); - xfs_finish_inode_setup(ip); -} - void xfs_irele(struct xfs_inode *ip); extern struct kmem_cache *xfs_inode_cache; diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 4ae81eed0442..99d6ecccdaa7 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -18,6 +18,7 @@ #include "xfs_buf_item.h" #include "xfs_log.h" #include "xfs_log_priv.h" +#include "xfs_ag.h" #include "xfs_error.h" #include "xfs_rtbitmap.h" @@ -34,7 +35,7 @@ static uint64_t xfs_inode_item_sort( struct xfs_log_item *lip) { - return INODE_ITEM(lip)->ili_inode->i_ino; + return I_INO(INODE_ITEM(lip)->ili_inode); } #ifdef DEBUG_EXPENSIVE @@ -54,7 +55,7 @@ xfs_inode_item_precommit_check( xfs_inode_to_disk(ip, dip, 0); xfs_dinode_calc_crc(mp, dip); - fa = xfs_dinode_verify(mp, ip->i_ino, dip); + fa = xfs_dinode_verify(mp, I_INO(ip), dip); if (fa) { xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, dip, sizeof(*dip), fa); @@ -104,6 +105,7 @@ xfs_inode_item_precommit( { struct xfs_inode_log_item *iip = INODE_ITEM(lip); struct xfs_inode *ip = iip->ili_inode; + struct xfs_mount *mp = ip->i_mount; struct inode *inode = VFS_I(ip); unsigned int flags = iip->ili_dirty_flags; @@ -124,8 +126,7 @@ xfs_inode_item_precommit( * to upgrade this inode to bigtime format, do so now. */ if ((flags & (XFS_ILOG_CORE | XFS_ILOG_TIMESTAMP)) && - xfs_has_bigtime(ip->i_mount) && - !xfs_inode_has_bigtime(ip)) { + xfs_has_bigtime(mp) && !xfs_inode_has_bigtime(ip)) { ip->i_diflags2 |= XFS_DIFLAG2_BIGTIME; flags |= XFS_ILOG_CORE; } @@ -138,14 +139,14 @@ xfs_inode_item_precommit( */ if (ip->i_diflags & XFS_DIFLAG_RTINHERIT) { if ((ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) && - xfs_extlen_to_rtxmod(ip->i_mount, ip->i_extsize) > 0) { + xfs_extlen_to_rtxmod(mp, ip->i_extsize) > 0) { ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT); ip->i_extsize = 0; flags |= XFS_ILOG_CORE; } if ((ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) && - xfs_extlen_to_rtxmod(ip->i_mount, ip->i_cowextsize) > 0) { + xfs_extlen_to_rtxmod(mp, ip->i_cowextsize) > 0) { ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; ip->i_cowextsize = 0; flags |= XFS_ILOG_CORE; @@ -154,6 +155,7 @@ xfs_inode_item_precommit( spin_lock(&iip->ili_lock); if (!iip->ili_item.li_buf) { + struct xfs_perag *pag; struct xfs_buf *bp; int error; @@ -167,7 +169,9 @@ xfs_inode_item_precommit( * here. */ spin_unlock(&iip->ili_lock); - error = xfs_imap_to_bp(ip->i_mount, tp, &ip->i_imap, &bp); + pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip)); + error = xfs_read_icluster(pag, tp, ip->i_imap.im_agbno, &bp); + xfs_perag_put(pag); if (error) return error; @@ -588,7 +592,7 @@ xfs_inode_to_log_dinode( to->di_flags2 = ip->i_diflags2; /* also covers the di_used_blocks union arm: */ to->di_cowextsize = ip->i_cowextsize; - to->di_ino = ip->i_ino; + to->di_ino = I_INO(ip); to->di_lsn = lsn; memset(to->di_pad2, 0, sizeof(to->di_pad2)); uuid_copy(&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid); @@ -647,13 +651,15 @@ xfs_inode_item_format( { struct xfs_inode_log_item *iip = INODE_ITEM(lip); struct xfs_inode *ip = iip->ili_inode; + struct xfs_mount *mp = ip->i_mount; struct xfs_inode_log_format *ilf; ilf = xlog_format_start(lfb, XLOG_REG_TYPE_IFORMAT); ilf->ilf_type = XFS_LI_INODE; - ilf->ilf_ino = ip->i_ino; - ilf->ilf_blkno = ip->i_imap.im_blkno; - ilf->ilf_len = ip->i_imap.im_len; + ilf->ilf_ino = I_INO(ip); + ilf->ilf_blkno = XFS_AGB_TO_DADDR(mp, XFS_INODE_TO_AGNO(ip), + ip->i_imap.im_agbno); + ilf->ilf_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster); ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields = XFS_ILOG_CORE; ilf->ilf_size = 2; /* format + core */ diff --git a/fs/xfs/xfs_inode_item_recover.c b/fs/xfs/xfs_inode_item_recover.c index b42106c4a9ef..169a8fe3bf0a 100644 --- a/fs/xfs/xfs_inode_item_recover.c +++ b/fs/xfs/xfs_inode_item_recover.c @@ -99,7 +99,7 @@ xfs_recover_inode_owner_change( if (in_f->ilf_fields & XFS_ILOG_DOWNER) { ASSERT(in_f->ilf_fields & XFS_ILOG_DBROOT); error = xfs_bmbt_change_owner(NULL, ip, XFS_DATA_FORK, - ip->i_ino, buffer_list); + I_INO(ip), buffer_list); if (error) goto out_free_ip; } @@ -107,7 +107,7 @@ xfs_recover_inode_owner_change( if (in_f->ilf_fields & XFS_ILOG_AOWNER) { ASSERT(in_f->ilf_fields & XFS_ILOG_ABROOT); error = xfs_bmbt_change_owner(NULL, ip, XFS_ATTR_FORK, - ip->i_ino, buffer_list); + I_INO(ip), buffer_list); if (error) goto out_free_ip; } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 904fc3d32449..1b53701bebea 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1005,7 +1005,7 @@ xfs_ioc_swapext( if (ip->i_mount != tip->i_mount) return -EINVAL; - if (ip->i_ino == tip->i_ino) + if (I_INO(ip) == I_INO(tip)) return -EINVAL; if (xfs_is_shutdown(ip->i_mount)) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index f20a02f49ed9..225c3de88d03 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -45,7 +45,7 @@ xfs_alert_fsblock_zero( "Access to block zero in inode %llu " "start_block: %llx start_off: %llx " "blkcnt: %llx extent-state: %x", - (unsigned long long)ip->i_ino, + (unsigned long long)I_INO(ip), (unsigned long long)imap->br_startblock, (unsigned long long)imap->br_startoff, (unsigned long long)imap->br_blockcount, @@ -113,6 +113,7 @@ xfs_bmbt_to_iomap( return xfs_alert_fsblock_zero(ip, imap); } + iomap->flags = iomap_flags; if (imap->br_startblock == HOLESTARTBLOCK) { iomap->addr = IOMAP_NULL_ADDR; iomap->type = IOMAP_HOLE; @@ -143,7 +144,6 @@ xfs_bmbt_to_iomap( } iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff); iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount); - iomap->flags = iomap_flags; if (mapping_flags & IOMAP_DAX) { iomap->dax_dev = target->bt_daxdev; } else { @@ -1736,7 +1736,7 @@ xfs_zoned_buffered_write_iomap_begin( if (count_fsb > ac->reserved_blocks) { xfs_warn_ratelimited(mp, "Short write on ino 0x%llx comm %.20s due to three-way race with write fault and direct I/O", - ip->i_ino, current->comm); + I_INO(ip), current->comm); count_fsb = ac->reserved_blocks; if (!count_fsb) { error = -EIO; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 325c2200c501..6339f4956ecb 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -703,7 +703,7 @@ xfs_vn_getattr( stat->nlink = inode->i_nlink; stat->uid = vfsuid_into_kuid(vfsuid); stat->gid = vfsgid_into_kgid(vfsgid); - stat->ino = ip->i_ino; + stat->ino = inode->i_ino; stat->atime = inode_get_atime(inode); fill_mg_cmtime(stat, request_mask, inode); @@ -1423,7 +1423,6 @@ xfs_setup_inode( gfp_t gfp_mask; bool is_meta = xfs_is_internal_inode(ip); - inode->i_ino = ip->i_ino; inode_state_set_raw(inode, I_NEW); inode_sb_list_add(inode); diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 97f106d2b4cd..159295c63e8f 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -97,7 +97,7 @@ xfs_bulkstat_one_int( } ASSERT(ip != NULL); - ASSERT(ip->i_imap.im_blkno != 0); + ASSERT(ip->i_imap.im_agbno != 0); inode = VFS_I(ip); vfsuid = i_uid_into_vfsuid(idmap, inode); vfsgid = i_gid_into_vfsgid(idmap, inode); diff --git a/fs/xfs/xfs_iunlink_item.c b/fs/xfs/xfs_iunlink_item.c index a03a48eeb9a8..d76d3f0434f1 100644 --- a/fs/xfs/xfs_iunlink_item.c +++ b/fs/xfs/xfs_iunlink_item.c @@ -40,7 +40,7 @@ static uint64_t xfs_iunlink_item_sort( struct xfs_log_item *lip) { - return IUL_ITEM(lip)->ip->i_ino; + return I_INO(IUL_ITEM(lip)->ip); } /* @@ -59,7 +59,7 @@ xfs_iunlink_log_dinode( int offset; int error; - error = xfs_imap_to_bp(tp->t_mountp, tp, &ip->i_imap, &ibp); + error = xfs_read_icluster(iup->pag, tp, ip->i_imap.im_agbno, &ibp); if (error) return error; /* diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 0f23812b0b31..ca66429bf6c9 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -80,23 +80,6 @@ xlog_format_copy( return buf; } -/* - * By comparing each component, we don't have to worry about extra - * endian issues in treating two 32 bit numbers as one 64 bit number - */ -static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2) -{ - if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2)) - return (CYCLE_LSN(lsn1)= 0 && feat < XFS_EXPERIMENTAL_MAX); BUILD_BUG_ON(ARRAY_SIZE(features) != XFS_EXPERIMENTAL_MAX); diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h index 49b0ef40d299..811b885f41c3 100644 --- a/fs/xfs/xfs_message.h +++ b/fs/xfs/xfs_message.h @@ -93,7 +93,6 @@ void xfs_buf_alert_ratelimited(struct xfs_buf *bp, const char *rlmsg, enum xfs_experimental_feat { XFS_EXPERIMENTAL_SHRINK, XFS_EXPERIMENTAL_LARP, - XFS_EXPERIMENTAL_ZONED, XFS_EXPERIMENTAL_MAX, }; diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 7aa51826b1ca..be90c7b03994 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -1080,7 +1080,7 @@ xfs_mountfs( if (XFS_IS_CORRUPT(mp, !S_ISDIR(VFS_I(rip)->i_mode))) { xfs_warn(mp, "corrupted root inode %llu: not a directory", - (unsigned long long)rip->i_ino); + (unsigned long long)I_INO(rip)); xfs_iunlock(rip, XFS_ILOCK_EXCL); error = -EFSCORRUPTED; goto out_rele_rip; @@ -1246,11 +1246,19 @@ xfs_mountfs( xfs_irele(mp->m_metadirip); /* - * Inactivate all inodes that might still be in memory after a log - * intent recovery failure so that reclaim can free them. Metadata - * inodes and the root directory shouldn't need inactivation, but the - * mount failed for some reason, so pull down all the state and flee. + * The mount has failed. Mark the filesystem shut down so that any + * inodes still queued for background inactivation are dropped + * straight to reclaim instead of being inactivated: a failed mount + * must not write to the (possibly corrupt, only partially set up) + * persistent metadata, and parts of the mount it would need - e.g. + * the quota subsystem (mp->m_quotainfo) - may never have been + * initialised. + * + * Flush the queue so that those inodes are pulled down and reclaim + * can free them; with the fs shut down xfs_inodegc_inactivate() + * turns each one reclaimable without touching the on-disk structures. */ + xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); xfs_inodegc_flush(mp); /* diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index d964bae096ef..66a02d1b9ad7 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -580,8 +580,6 @@ __XFS_HAS_FEAT(nouuid, NOUUID) #define XFS_OPSTATE_WARNED_METADIR 17 /* Filesystem should use qflags to determine quotaon status */ #define XFS_OPSTATE_RESUMING_QUOTAON 18 -/* Kernel has logged a warning about zoned RT device being used on this fs. */ -#define XFS_OPSTATE_WARNED_ZONED 19 /* (Zoned) GC is in progress */ #define XFS_OPSTATE_ZONEGC_RUNNING 20 diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 7bd15d9e7fba..aa0d2976f1c3 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -297,7 +297,7 @@ xfs_qm_need_dqattach( return false; if (!XFS_NOT_DQATTACHED(mp, ip)) return false; - if (xfs_is_quota_inode(&mp->m_sb, ip->i_ino)) + if (xfs_is_quota_inode(&mp->m_sb, I_INO(ip))) return false; if (xfs_is_metadir_inode(ip)) return false; @@ -390,7 +390,7 @@ xfs_qm_dqdetach( trace_xfs_dquot_dqdetach(ip); - ASSERT(!xfs_is_quota_inode(&ip->i_mount->m_sb, ip->i_ino)); + ASSERT(!xfs_is_quota_inode(&ip->i_mount->m_sb, I_INO(ip))); if (ip->i_udquot) { xfs_qm_dqrele(ip->i_udquot); ip->i_udquot = NULL; @@ -986,11 +986,11 @@ xfs_qm_qino_alloc( mp->m_sb.sb_qflags = mp->m_qflags & XFS_ALL_QUOTA_ACCT; } if (flags & XFS_QMOPT_UQUOTA) - mp->m_sb.sb_uquotino = (*ipp)->i_ino; + mp->m_sb.sb_uquotino = I_INO(*ipp); else if (flags & XFS_QMOPT_GQUOTA) - mp->m_sb.sb_gquotino = (*ipp)->i_ino; + mp->m_sb.sb_gquotino = I_INO(*ipp); else - mp->m_sb.sb_pquotino = (*ipp)->i_ino; + mp->m_sb.sb_pquotino = I_INO(*ipp); spin_unlock(&mp->m_sb_lock); xfs_log_sb(tp); diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c index 8804508cc2b8..81f739e3aa0c 100644 --- a/fs/xfs/xfs_quotaops.c +++ b/fs/xfs/xfs_quotaops.c @@ -34,7 +34,7 @@ xfs_qm_fill_state( defq = xfs_get_defquota(mp->m_quotainfo, type); - tstate->ino = ip->i_ino; + tstate->ino = I_INO(ip); tstate->flags |= QCI_SYSFILE; tstate->blocks = ip->i_nblocks; tstate->nextents = ip->i_df.if_nextents; diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 251dec48f0e3..a5c188b78138 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1188,7 +1188,7 @@ xfs_reflink_set_inode_flag( goto out_error; /* Lock both files against IO */ - if (src->i_ino == dest->i_ino) + if (I_INO(src) == I_INO(dest)) xfs_ilock(src, XFS_ILOCK_EXCL); else xfs_lock_two_inodes(src, XFS_ILOCK_EXCL, dest, XFS_ILOCK_EXCL); @@ -1202,7 +1202,7 @@ xfs_reflink_set_inode_flag( } else xfs_iunlock(src, XFS_ILOCK_EXCL); - if (src->i_ino == dest->i_ino) + if (I_INO(src) == I_INO(dest)) goto commit_flags; if (!xfs_is_reflink_inode(dest)) { diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 153f3c378f9f..7a3f97686989 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -890,8 +890,7 @@ xfs_growfs_rt_sb_fields( static int xfs_growfs_rt_zoned( - struct xfs_rtgroup *rtg, - xfs_rfsblock_t nrblocks) + struct xfs_rtgroup *rtg) { struct xfs_mount *mp = rtg_mount(rtg); struct xfs_mount *nmp; @@ -903,7 +902,8 @@ xfs_growfs_rt_zoned( * Calculate new sb and mount fields for this round. Also ensure the * rtg_extents value is uptodate as the rtbitmap code relies on it. */ - nmp = xfs_growfs_rt_alloc_fake_mount(mp, nrblocks, + nmp = xfs_growfs_rt_alloc_fake_mount(mp, + xfs_rtgs_to_rfsbs(mp, rtg_rgno(rtg) + 1), mp->m_sb.sb_rextsize); if (!nmp) return -ENOMEM; @@ -933,6 +933,14 @@ xfs_growfs_rt_zoned( mp->m_features |= XFS_FEAT_REALTIME; xfs_rtrmapbt_compute_maxlevels(mp); xfs_rtrefcountbt_compute_maxlevels(mp); + + /* + * Finally add the newly added zone to the freelist and add the space + * to the available counter. The order is important here: only add + * the available space after the zones, as available space guarantees + * that zones to back it are available. + */ + xfs_zone_mark_free(rtg); xfs_zoned_add_available(mp, freed_rtx); out_free: kfree(nmp); @@ -1218,7 +1226,7 @@ xfs_growfs_rtg( } if (xfs_has_zoned(mp)) { - error = xfs_growfs_rt_zoned(rtg, nrblocks); + error = xfs_growfs_rt_zoned(rtg); goto out_rele; } diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index f8de44443e81..eac7f9503805 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1901,7 +1901,6 @@ xfs_fs_fill_super( error = -EINVAL; goto out_filestream_unmount; } - xfs_warn_experimental(mp, XFS_EXPERIMENTAL_ZONED); } if (xfs_has_reflink(mp)) { diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index c4da624fb296..5585ac7f4d16 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -52,7 +52,7 @@ xfs_readlink( if (pathlen < 0 || pathlen > XFS_SYMLINK_MAXLEN) { xfs_alert(mp, "%s: inode (%llu) bad symlink length (%lld)", - __func__, (unsigned long long) ip->i_ino, + __func__, (unsigned long long)I_INO(ip), (long long) pathlen); ASSERT(0); goto out_corrupt; @@ -186,7 +186,7 @@ xfs_symlink( xfs_qm_vop_create_dqattach(tp, du.ip, udqp, gdqp, pdqp); resblks -= XFS_IALLOC_SPACE_RES(mp); - error = xfs_symlink_write_target(tp, du.ip, du.ip->i_ino, target_path, + error = xfs_symlink_write_target(tp, du.ip, I_INO(du.ip), target_path, pathlen, fs_blocks, resblks); if (error) goto out_trans_cancel; @@ -339,7 +339,7 @@ xfs_inactive_symlink( if (pathlen <= 0 || pathlen > XFS_SYMLINK_MAXLEN) { xfs_alert(mp, "%s: inode (0x%llx) bad symlink length (%d)", - __func__, (unsigned long long)ip->i_ino, pathlen); + __func__, (unsigned long long)I_INO(ip), pathlen); xfs_iunlock(ip, XFS_ILOCK_EXCL); ASSERT(0); xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK); diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index f87c738d84b2..d478693674f9 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -132,7 +132,7 @@ DECLARE_EVENT_CLASS(xfs_attr_list_class, ), TP_fast_assign( __entry->dev = VFS_I(ctx->dp)->i_sb->s_dev; - __entry->ino = ctx->dp->i_ino; + __entry->ino = I_INO(ctx->dp); __entry->hashval = ctx->cursor.hashval; __entry->blkno = ctx->cursor.blkno; __entry->offset = ctx->cursor.offset; @@ -634,7 +634,7 @@ TRACE_EVENT(xfs_attr_list_node_descend, ), TP_fast_assign( __entry->dev = VFS_I(ctx->dp)->i_sb->s_dev; - __entry->ino = ctx->dp->i_ino; + __entry->ino = I_INO(ctx->dp); __entry->hashval = ctx->cursor.hashval; __entry->blkno = ctx->cursor.blkno; __entry->offset = ctx->cursor.offset; @@ -688,7 +688,7 @@ DECLARE_EVENT_CLASS(xfs_bmap_class, ifp = xfs_iext_state_to_fork(ip, state); xfs_iext_get_extent(ifp, cur, &r); __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->leaf = cur->leaf; __entry->pos = cur->pos; __entry->startoff = r.br_startoff; @@ -1021,7 +1021,7 @@ DECLARE_EVENT_CLASS(xfs_lock_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->lock_flags = lock_flags; __entry->caller_ip = caller_ip; ), @@ -1052,7 +1052,7 @@ DECLARE_EVENT_CLASS(xfs_inode_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->iflags = ip->i_flags; ), TP_printk("dev %d:%d ino 0x%llx iflags 0x%lx", @@ -1128,7 +1128,7 @@ DECLARE_EVENT_CLASS(xfs_fault_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->order = order; ), TP_printk("dev %d:%d ino 0x%llx order %u", @@ -1157,7 +1157,7 @@ DECLARE_EVENT_CLASS(xfs_iref_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->count = icount_read_once(VFS_I(ip)); __entry->pincount = atomic_read(&ip->i_pincount); __entry->iflags = ip->i_flags; @@ -1185,7 +1185,7 @@ TRACE_EVENT(xfs_iomap_prealloc_size, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->blocks = blocks; __entry->shift = shift; __entry->writeio_blocks = writeio_blocks; @@ -1272,7 +1272,7 @@ DECLARE_EVENT_CLASS(xfs_namespace_class, ), TP_fast_assign( __entry->dev = VFS_I(dp)->i_sb->s_dev; - __entry->dp_ino = dp->i_ino; + __entry->dp_ino = I_INO(dp); __entry->namelen = name->len; memcpy(__get_str(name), name->name, name->len); ), @@ -1308,8 +1308,8 @@ TRACE_EVENT(xfs_rename, ), TP_fast_assign( __entry->dev = VFS_I(src_dp)->i_sb->s_dev; - __entry->src_dp_ino = src_dp->i_ino; - __entry->target_dp_ino = target_dp->i_ino; + __entry->src_dp_ino = I_INO(src_dp); + __entry->target_dp_ino = I_INO(target_dp); __entry->src_namelen = src_name->len; __entry->target_namelen = target_name->len; memcpy(__get_str(src_name), src_name->name, src_name->len); @@ -1760,7 +1760,7 @@ DECLARE_EVENT_CLASS(xfs_file_class, ), TP_fast_assign( __entry->dev = file_inode(iocb->ki_filp)->i_sb->s_dev; - __entry->ino = XFS_I(file_inode(iocb->ki_filp))->i_ino; + __entry->ino = file_inode(iocb->ki_filp)->i_ino; __entry->size = XFS_I(file_inode(iocb->ki_filp))->i_disk_size; __entry->offset = iocb->ki_pos; __entry->count = iov_iter_count(iter); @@ -1796,7 +1796,7 @@ TRACE_EVENT(xfs_iomap_atomic_write_cow, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->offset = offset; __entry->count = count; ), @@ -1824,7 +1824,7 @@ DECLARE_EVENT_CLASS(xfs_imap_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->size = ip->i_disk_size; __entry->offset = offset; __entry->count = count; @@ -1869,7 +1869,7 @@ DECLARE_EVENT_CLASS(xfs_simple_io_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->isize = VFS_I(ip)->i_size; __entry->disize = ip->i_disk_size; __entry->offset = offset; @@ -1908,7 +1908,7 @@ DECLARE_EVENT_CLASS(xfs_itrunc_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->size = ip->i_disk_size; __entry->new_size = new_size; ), @@ -1941,7 +1941,7 @@ TRACE_EVENT(xfs_bunmap, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->size = ip->i_disk_size; __entry->fileoff = fileoff; __entry->len = len; @@ -2344,7 +2344,7 @@ DECLARE_EVENT_CLASS(xfs_da_class, ), TP_fast_assign( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; - __entry->ino = args->dp->i_ino; + __entry->ino = I_INO(args->dp); if (args->namelen) memcpy(__get_str(name), args->name, args->namelen); __entry->namelen = args->namelen; @@ -2411,7 +2411,7 @@ DECLARE_EVENT_CLASS(xfs_attr_class, ), TP_fast_assign( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; - __entry->ino = args->dp->i_ino; + __entry->ino = I_INO(args->dp); if (args->namelen) memcpy(__get_str(name), args->name, args->namelen); __entry->namelen = args->namelen; @@ -2511,7 +2511,7 @@ DECLARE_EVENT_CLASS(xfs_dir2_space_class, ), TP_fast_assign( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; - __entry->ino = args->dp->i_ino; + __entry->ino = I_INO(args->dp); __entry->op_flags = args->op_flags; __entry->idx = idx; ), @@ -2544,7 +2544,7 @@ TRACE_EVENT(xfs_dir2_leafn_moveents, ), TP_fast_assign( __entry->dev = VFS_I(args->dp)->i_sb->s_dev; - __entry->ino = args->dp->i_ino; + __entry->ino = I_INO(args->dp); __entry->op_flags = args->op_flags; __entry->src_idx = src_idx; __entry->dst_idx = dst_idx; @@ -2586,7 +2586,7 @@ DECLARE_EVENT_CLASS(xfs_swap_extent_class, TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; __entry->which = which; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->format = ip->i_df.if_format; __entry->nex = ip->i_df.if_nextents; __entry->broot_size = ip->i_df.if_broot_bytes; @@ -2944,7 +2944,7 @@ TRACE_EVENT(xfs_btree_alloc_block, switch (cur->bc_ops->type) { case XFS_BTREE_TYPE_INODE: __entry->agno = 0; - __entry->ino = cur->bc_ino.ip->i_ino; + __entry->ino = I_INO(cur->bc_ino.ip); break; case XFS_BTREE_TYPE_AG: __entry->agno = cur->bc_group->xg_gno; @@ -2996,7 +2996,7 @@ TRACE_EVENT(xfs_btree_free_block, __entry->agno = xfs_daddr_to_agno(cur->bc_mp, xfs_buf_daddr(bp)); if (cur->bc_ops->type == XFS_BTREE_TYPE_INODE) - __entry->ino = cur->bc_ino.ip->i_ino; + __entry->ino = I_INO(cur->bc_ino.ip); else __entry->ino = 0; __assign_str(name); @@ -3251,7 +3251,7 @@ DECLARE_EVENT_CLASS(xfs_btree_error_class, switch (cur->bc_ops->type) { case XFS_BTREE_TYPE_INODE: __entry->agno = 0; - __entry->ino = cur->bc_ino.ip->i_ino; + __entry->ino = I_INO(cur->bc_ino.ip); break; case XFS_BTREE_TYPE_AG: __entry->agno = cur->bc_group->xg_gno; @@ -3470,7 +3470,7 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class, bi->bi_bmap.br_startblock, bi->bi_group->xg_type); } - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->whichfork = bi->bi_whichfork; __entry->l_loff = bi->bi_bmap.br_startoff; __entry->l_len = bi->bi_bmap.br_blockcount; @@ -3974,7 +3974,7 @@ DECLARE_EVENT_CLASS(xfs_inode_error_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->error = error; __entry->caller_ip = caller_ip; ), @@ -4012,12 +4012,12 @@ DECLARE_EVENT_CLASS(xfs_double_io_class, ), TP_fast_assign( __entry->dev = VFS_I(src)->i_sb->s_dev; - __entry->src_ino = src->i_ino; + __entry->src_ino = I_INO(src); __entry->src_isize = VFS_I(src)->i_size; __entry->src_disize = src->i_disk_size; __entry->src_offset = soffset; __entry->len = len; - __entry->dest_ino = dest->i_ino; + __entry->dest_ino = I_INO(dest); __entry->dest_isize = VFS_I(dest)->i_size; __entry->dest_disize = dest->i_disk_size; __entry->dest_offset = doffset; @@ -4057,7 +4057,7 @@ DECLARE_EVENT_CLASS(xfs_inode_irec_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->lblk = irec->br_startoff; __entry->len = irec->br_blockcount; __entry->pblk = irec->br_startblock; @@ -4093,7 +4093,7 @@ DECLARE_EVENT_CLASS(xfs_wb_invalid_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->addr = iomap->addr; __entry->pos = iomap->offset; __entry->len = iomap->length; @@ -4136,7 +4136,7 @@ DECLARE_EVENT_CLASS(xfs_iomap_invalid_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->addr = iomap->addr; __entry->pos = iomap->offset; __entry->len = iomap->length; @@ -4183,10 +4183,10 @@ TRACE_EVENT(xfs_reflink_remap_blocks, ), TP_fast_assign( __entry->dev = VFS_I(src)->i_sb->s_dev; - __entry->src_ino = src->i_ino; + __entry->src_ino = I_INO(src); __entry->src_lblk = soffset; __entry->len = len; - __entry->dest_ino = dest->i_ino; + __entry->dest_ino = I_INO(dest); __entry->dest_lblk = doffset; ), TP_printk("dev %d:%d fsbcount 0x%llx " @@ -4504,8 +4504,7 @@ TRACE_EVENT(xfs_iunlink_update_dinode, TP_fast_assign( __entry->dev = pag_mount(iup->pag)->m_super->s_dev; __entry->agno = pag_agno(iup->pag); - __entry->agino = - XFS_INO_TO_AGINO(iup->ip->i_mount, iup->ip->i_ino); + __entry->agino = XFS_INODE_TO_AGINO(iup->ip); __entry->old_ptr = old_ptr; __entry->new_ptr = iup->next_agino; ), @@ -4529,8 +4528,8 @@ TRACE_EVENT(xfs_iunlink_reload_next, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(ip); + __entry->agino = XFS_INODE_TO_AGINO(ip); __entry->prev_agino = ip->i_prev_unlinked; __entry->next_agino = ip->i_next_unlinked; ), @@ -4552,8 +4551,8 @@ TRACE_EVENT(xfs_inode_reload_unlinked_bucket, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(ip); + __entry->agino = XFS_INODE_TO_AGINO(ip); ), TP_printk("dev %d:%d agno 0x%x agino 0x%x bucket %u", MAJOR(__entry->dev), MINOR(__entry->dev), @@ -4572,8 +4571,8 @@ DECLARE_EVENT_CLASS(xfs_ag_inode_class, ), TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->agno = XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(ip); + __entry->agino = XFS_INODE_TO_AGINO(ip); ), TP_printk("dev %d:%d agno 0x%x agino 0x%x", MAJOR(__entry->dev), MINOR(__entry->dev), @@ -4650,7 +4649,7 @@ DECLARE_EVENT_CLASS(xfs_inode_corrupt_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->flags = flags; ), TP_printk("dev %d:%d ino 0x%llx flags 0x%x", @@ -4769,10 +4768,8 @@ TRACE_EVENT(xfs_btree_commit_ifakeroot, TP_fast_assign( __entry->dev = cur->bc_mp->m_super->s_dev; __assign_str(name); - __entry->agno = XFS_INO_TO_AGNO(cur->bc_mp, - cur->bc_ino.ip->i_ino); - __entry->agino = XFS_INO_TO_AGINO(cur->bc_mp, - cur->bc_ino.ip->i_ino); + __entry->agno = XFS_INODE_TO_AGNO(cur->bc_ino.ip); + __entry->agino = XFS_INODE_TO_AGINO(cur->bc_ino.ip); __entry->levels = cur->bc_ino.ifake->if_levels; __entry->blocks = cur->bc_ino.ifake->if_blocks; __entry->whichfork = cur->bc_ino.whichfork; @@ -5031,7 +5028,7 @@ DECLARE_EVENT_CLASS(xfs_das_state_class, ), TP_fast_assign( __entry->das = das; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); ), TP_printk("state change %s ino 0x%llx", __print_symbolic(__entry->das, XFS_DAS_STRINGS), @@ -5296,7 +5293,7 @@ DECLARE_EVENT_CLASS(xfs_exchrange_inode_class, TP_fast_assign( __entry->dev = VFS_I(ip)->i_sb->s_dev; __entry->whichfile = whichfile; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->format = ip->i_df.if_format; __entry->nex = ip->i_df.if_nextents; __entry->fork_off = xfs_inode_fork_boff(ip); @@ -5349,10 +5346,10 @@ DECLARE_EVENT_CLASS(xfs_exchrange_class, ), TP_fast_assign( __entry->dev = VFS_I(ip1)->i_sb->s_dev; - __entry->ip1_ino = ip1->i_ino; + __entry->ip1_ino = I_INO(ip1); __entry->ip1_isize = VFS_I(ip1)->i_size; __entry->ip1_disize = ip1->i_disk_size; - __entry->ip2_ino = ip2->i_ino; + __entry->ip2_ino = I_INO(ip2); __entry->ip2_isize = VFS_I(ip2)->i_size; __entry->ip2_disize = ip2->i_disk_size; @@ -5408,7 +5405,7 @@ TRACE_EVENT(xfs_exchrange_freshness, struct inode *inode2 = VFS_I(ip2); __entry->dev = inode2->i_sb->s_dev; - __entry->ip2_ino = ip2->i_ino; + __entry->ip2_ino = I_INO(ip2); ts64 = inode_get_ctime(inode2); __entry->ip2_ctime = ts64.tv_sec; @@ -5480,8 +5477,8 @@ DECLARE_EVENT_CLASS(xfs_exchmaps_estimate_class, ), TP_fast_assign( __entry->dev = req->ip1->i_mount->m_super->s_dev; - __entry->ino1 = req->ip1->i_ino; - __entry->ino2 = req->ip2->i_ino; + __entry->ino1 = I_INO(req->ip1); + __entry->ino2 = I_INO(req->ip2); __entry->startoff1 = req->startoff1; __entry->startoff2 = req->startoff2; __entry->blockcount = req->blockcount; @@ -5532,8 +5529,8 @@ DECLARE_EVENT_CLASS(xfs_exchmaps_intent_class, ), TP_fast_assign( __entry->dev = mp->m_super->s_dev; - __entry->ino1 = xmi->xmi_ip1->i_ino; - __entry->ino2 = xmi->xmi_ip2->i_ino; + __entry->ino1 = I_INO(xmi->xmi_ip1); + __entry->ino2 = I_INO(xmi->xmi_ip2); __entry->flags = xmi->xmi_flags; __entry->startoff1 = xmi->xmi_startoff1; __entry->startoff2 = xmi->xmi_startoff2; @@ -5628,8 +5625,8 @@ TRACE_EVENT(xfs_exchmaps_delta_nextents, int whichfork = xfs_exchmaps_reqfork(req); __entry->dev = req->ip1->i_mount->m_super->s_dev; - __entry->ino1 = req->ip1->i_ino; - __entry->ino2 = req->ip2->i_ino; + __entry->ino1 = I_INO(req->ip1); + __entry->ino2 = I_INO(req->ip2); __entry->nexts1 = xfs_ifork_ptr(req->ip1, whichfork)->if_nextents; __entry->nexts2 = xfs_ifork_ptr(req->ip2, whichfork)->if_nextents; __entry->d_nexts1 = d_nexts1; @@ -5659,7 +5656,7 @@ DECLARE_EVENT_CLASS(xfs_getparents_rec_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->firstu = context->firstu; __entry->reclen = pptr->gpr_reclen; __entry->bufsize = ppi->gp_bufsize; @@ -5703,7 +5700,7 @@ DECLARE_EVENT_CLASS(xfs_getparents_class, ), TP_fast_assign( __entry->dev = ip->i_mount->m_super->s_dev; - __entry->ino = ip->i_ino; + __entry->ino = I_INO(ip); __entry->iflags = ppi->gp_iflags; __entry->oflags = ppi->gp_oflags; __entry->bufsize = ppi->gp_bufsize; @@ -5742,8 +5739,8 @@ DECLARE_EVENT_CLASS(xfs_metadir_update_class, ), TP_fast_assign( __entry->dev = upd->dp->i_mount->m_super->s_dev; - __entry->dp_ino = upd->dp->i_ino; - __entry->ino = upd->ip ? upd->ip->i_ino : NULLFSINO; + __entry->dp_ino = I_INO(upd->dp); + __entry->ino = upd->ip ? I_INO(upd->ip) : NULLFSINO; __assign_str(fname); ), TP_printk("dev %d:%d dp 0x%llx fname '%s' ino 0x%llx", @@ -5777,8 +5774,8 @@ DECLARE_EVENT_CLASS(xfs_metadir_update_error_class, ), TP_fast_assign( __entry->dev = upd->dp->i_mount->m_super->s_dev; - __entry->dp_ino = upd->dp->i_ino; - __entry->ino = upd->ip ? upd->ip->i_ino : NULLFSINO; + __entry->dp_ino = I_INO(upd->dp); + __entry->ino = upd->ip ? I_INO(upd->ip) : NULLFSINO; __entry->error = error; __assign_str(fname); ), @@ -5810,7 +5807,7 @@ DECLARE_EVENT_CLASS(xfs_metadir_class, ), TP_fast_assign( __entry->dev = VFS_I(dp)->i_sb->s_dev; - __entry->dp_ino = dp->i_ino; + __entry->dp_ino = I_INO(dp); __entry->ino = ino, __entry->ftype = name->type; __entry->namelen = name->len; @@ -6328,7 +6325,7 @@ TRACE_EVENT(xfs_healthmon_report_file_ioerror, TP_fast_assign( __entry->dev = hm->dev; __entry->type = p->type; - __entry->ino = XFS_I(p->inode)->i_ino; + __entry->ino = p->inode->i_ino; __entry->gen = p->inode->i_generation; __entry->pos = p->pos; __entry->len = p->len; diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 148cc32449c1..7bfbd9f6f0df 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1164,7 +1164,7 @@ xfs_trans_reserve_more_inode( if (error) return error; - if (!XFS_IS_QUOTA_ON(mp) || xfs_is_quota_inode(&mp->m_sb, ip->i_ino)) + if (!XFS_IS_QUOTA_ON(mp) || xfs_is_quota_inode(&mp->m_sb, I_INO(ip))) return 0; if (tp->t_flags & XFS_TRANS_RESERVE) diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 95db73a37e57..7e17b93fe9ad 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c @@ -234,7 +234,6 @@ xfs_trans_read_buf_map( const struct xfs_buf_ops *ops) { struct xfs_buf *bp = NULL; - struct xfs_buf_log_item *bip; int error; *bpp = NULL; @@ -251,9 +250,10 @@ xfs_trans_read_buf_map( if (bp) { ASSERT(xfs_buf_islocked(bp)); ASSERT(bp->b_transp == tp); - ASSERT(bp->b_log_item != NULL); ASSERT(!bp->b_error); ASSERT(bp->b_flags & XBF_DONE); + ASSERT(atomic_read(&bp->b_log_item->bli_refcount) > 0); + ASSERT(bp->b_ops); /* * We never locked this buf ourselves, so we shouldn't @@ -264,39 +264,8 @@ xfs_trans_read_buf_map( return -EIO; } - /* - * Check if the caller is trying to read a buffer that is - * already attached to the transaction yet has no buffer ops - * assigned. Ops are usually attached when the buffer is - * attached to the transaction, or by the read caller if - * special circumstances. That didn't happen, which is not - * how this is supposed to go. - * - * If the buffer passes verification we'll let this go, but if - * not we have to shut down. Let the transaction cleanup code - * release this buffer when it kills the tranaction. - */ - ASSERT(bp->b_ops != NULL); - error = xfs_buf_reverify(bp, ops); - if (error) { - xfs_buf_ioerror_alert(bp, __return_address); - - if (tp->t_flags & XFS_TRANS_DIRTY) - xfs_force_shutdown(tp->t_mountp, - SHUTDOWN_META_IO_ERROR); - - /* bad CRC means corrupted metadata */ - if (error == -EFSBADCRC) - error = -EFSCORRUPTED; - return error; - } - - bip = bp->b_log_item; - bip->bli_recur++; - - ASSERT(atomic_read(&bip->bli_refcount) > 0); - trace_xfs_trans_read_buf_recur(bip); - ASSERT(bp->b_ops != NULL || ops == NULL); + bp->b_log_item->bli_recur++; + trace_xfs_trans_read_buf_recur(bp->b_log_item); *bpp = bp; return 0; } diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index eaf9de6e07fd..1606c614f205 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -164,7 +164,7 @@ xfs_trans_mod_ino_dquot( if (xfs_hooks_switched_on(&xfs_dqtrx_hooks_switch)) { struct xfs_mod_ino_dqtrx_params p = { .tx_id = (uintptr_t)tp, - .ino = ip->i_ino, + .ino = I_INO(ip), .q_type = xfs_dquot_type(dqp), .q_id = dqp->q_id, .delta = delta @@ -247,7 +247,7 @@ xfs_trans_mod_dquot_byino( xfs_mount_t *mp = tp->t_mountp; if (!XFS_IS_QUOTA_ON(mp) || - xfs_is_quota_inode(&mp->m_sb, ip->i_ino) || + xfs_is_quota_inode(&mp->m_sb, I_INO(ip)) || xfs_is_metadir_inode(ip)) return; @@ -990,7 +990,7 @@ xfs_trans_reserve_quota_nblks( if (xfs_is_metadir_inode(ip)) return 0; - ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino)); + ASSERT(!xfs_is_quota_inode(&mp->m_sb, I_INO(ip))); xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); if (force) diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 544213067d59..1efe6c8139b2 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -104,7 +104,7 @@ xfs_attr_change( args->op_flags |= XFS_DA_OP_LOGGED; } - args->owner = args->dp->i_ino; + args->owner = I_INO(args->dp); args->geo = mp->m_attr_geo; args->whichfork = XFS_ATTR_FORK; xfs_attr_sethash(args); diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c index 5e297b75a85f..08d8b34f467e 100644 --- a/fs/xfs/xfs_zone_alloc.c +++ b/fs/xfs/xfs_zone_alloc.c @@ -944,6 +944,14 @@ xfs_zone_rgbno_is_valid( rtg_rgno(rtg), XFS_RTG_FREE); } +void +xfs_zone_mark_free( + struct xfs_rtgroup *rtg) +{ + xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE); + atomic_inc(&rtg_mount(rtg)->m_zone_info->zi_nr_free_zones); +} + static void xfs_free_open_zones( struct xfs_zone_info *zi) @@ -1082,8 +1090,7 @@ xfs_init_zone( if (write_pointer == 0) { /* zone is empty */ - atomic_inc(&zi->zi_nr_free_zones); - xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE); + xfs_zone_mark_free(rtg); iz->available += rtg_blocks(rtg); } else if (write_pointer < rtg_blocks(rtg)) { /* zone is open */ diff --git a/fs/xfs/xfs_zone_alloc.h b/fs/xfs/xfs_zone_alloc.h index 8b2ef98c81ef..abf8358bb266 100644 --- a/fs/xfs/xfs_zone_alloc.h +++ b/fs/xfs/xfs_zone_alloc.h @@ -42,6 +42,7 @@ void xfs_zoned_wake_all(struct xfs_mount *mp); bool xfs_zone_rgbno_is_valid(struct xfs_rtgroup *rtg, xfs_rgnumber_t rgbno); void xfs_mark_rtg_boundary(struct iomap_ioend *ioend); +void xfs_zone_mark_free(struct xfs_rtgroup *rtg); uint64_t xfs_zoned_default_resblks(struct xfs_mount *mp, enum xfs_free_counter ctr); void xfs_zoned_show_stats(struct seq_file *m, struct xfs_mount *mp); diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c index f03211e4354a..f76a09130852 100644 --- a/fs/xfs/xfs_zone_gc.c +++ b/fs/xfs/xfs_zone_gc.c @@ -924,9 +924,7 @@ xfs_zone_gc_finish_reset( goto out; } - xfs_group_set_mark(rtg_group(rtg), XFS_RTG_FREE); - atomic_inc(&zi->zi_nr_free_zones); - + xfs_zone_mark_free(rtg); xfs_zoned_add_available(mp, rtg_blocks(rtg)); wake_up_all(&zi->zi_zone_wait);