Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'master' of git://oss.sgi.com/xfs/xfs into for-linus

Conflicts:
fs/xfs/linux-2.6/xfs_lrw.c

+598 -933
+1 -1
MAINTAINERS
··· 5694 5694 5695 5695 XFS FILESYSTEM 5696 5696 P: Silicon Graphics Inc 5697 - M: Felix Blyakher <felixb@sgi.com> 5697 + M: Alex Elder <aelder@sgi.com> 5698 5698 M: xfs-masters@oss.sgi.com 5699 5699 L: xfs@oss.sgi.com 5700 5700 W: http://oss.sgi.com/projects/xfs
-1
fs/xfs/linux-2.6/xfs_aops.c
··· 216 216 if (ip->i_d.di_size < isize) { 217 217 ip->i_d.di_size = isize; 218 218 ip->i_update_core = 1; 219 - ip->i_update_size = 1; 220 219 xfs_mark_inode_dirty_sync(ip); 221 220 } 222 221
+14 -5
fs/xfs/linux-2.6/xfs_file.c
··· 172 172 */ 173 173 STATIC int 174 174 xfs_file_fsync( 175 - struct file *filp, 176 - struct dentry *dentry, 177 - int datasync) 175 + struct file *file, 176 + struct dentry *dentry, 177 + int datasync) 178 178 { 179 - xfs_iflags_clear(XFS_I(dentry->d_inode), XFS_ITRUNCATED); 180 - return -xfs_fsync(XFS_I(dentry->d_inode)); 179 + struct inode *inode = dentry->d_inode; 180 + struct xfs_inode *ip = XFS_I(inode); 181 + int error; 182 + 183 + /* capture size updates in I/O completion before writing the inode. */ 184 + error = filemap_fdatawait(inode->i_mapping); 185 + if (error) 186 + return error; 187 + 188 + xfs_iflags_clear(ip, XFS_ITRUNCATED); 189 + return -xfs_fsync(ip); 181 190 } 182 191 183 192 STATIC int
-1
fs/xfs/linux-2.6/xfs_iops.c
··· 43 43 #include "xfs_error.h" 44 44 #include "xfs_itable.h" 45 45 #include "xfs_rw.h" 46 - #include "xfs_acl.h" 47 46 #include "xfs_attr.h" 48 47 #include "xfs_buf_item.h" 49 48 #include "xfs_utils.h"
+5 -3
fs/xfs/linux-2.6/xfs_lrw.c
··· 812 812 813 813 /* Handle various SYNC-type writes */ 814 814 if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { 815 + loff_t end = pos + ret - 1; 815 816 int error2; 816 817 817 818 xfs_iunlock(xip, iolock); 818 819 if (need_i_mutex) 819 820 mutex_unlock(&inode->i_mutex); 820 - error2 = filemap_write_and_wait_range(mapping, pos, 821 - pos + ret - 1); 821 + 822 + error2 = filemap_write_and_wait_range(mapping, pos, end); 822 823 if (!error) 823 824 error = error2; 824 825 if (need_i_mutex) 825 826 mutex_lock(&inode->i_mutex); 826 827 xfs_ilock(xip, iolock); 827 - error2 = xfs_write_sync_logforce(mp, xip); 828 + 829 + error2 = xfs_fsync(xip); 828 830 if (!error) 829 831 error = error2; 830 832 }
+24 -29
fs/xfs/linux-2.6/xfs_stats.c
··· 20 20 21 21 DEFINE_PER_CPU(struct xfsstats, xfsstats); 22 22 23 - STATIC int 24 - xfs_read_xfsstats( 25 - char *buffer, 26 - char **start, 27 - off_t offset, 28 - int count, 29 - int *eof, 30 - void *data) 23 + static int xfs_stat_proc_show(struct seq_file *m, void *v) 31 24 { 32 - int c, i, j, len, val; 25 + int c, i, j, val; 33 26 __uint64_t xs_xstrat_bytes = 0; 34 27 __uint64_t xs_write_bytes = 0; 35 28 __uint64_t xs_read_bytes = 0; ··· 53 60 }; 54 61 55 62 /* Loop over all stats groups */ 56 - for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) { 57 - len += sprintf(buffer + len, "%s", xstats[i].desc); 63 + for (i=j = 0; i < ARRAY_SIZE(xstats); i++) { 64 + seq_printf(m, "%s", xstats[i].desc); 58 65 /* inner loop does each group */ 59 66 while (j < xstats[i].endpoint) { 60 67 val = 0; 61 68 /* sum over all cpus */ 62 69 for_each_possible_cpu(c) 63 70 val += *(((__u32*)&per_cpu(xfsstats, c) + j)); 64 - len += sprintf(buffer + len, " %u", val); 71 + seq_printf(m, " %u", val); 65 72 j++; 66 73 } 67 - buffer[len++] = '\n'; 74 + seq_putc(m, '\n'); 68 75 } 69 76 /* extra precision counters */ 70 77 for_each_possible_cpu(i) { ··· 73 80 xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes; 74 81 } 75 82 76 - len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n", 83 + seq_printf(m, "xpc %Lu %Lu %Lu\n", 77 84 xs_xstrat_bytes, xs_write_bytes, xs_read_bytes); 78 - len += sprintf(buffer + len, "debug %u\n", 85 + seq_printf(m, "debug %u\n", 79 86 #if defined(DEBUG) 80 87 1); 81 88 #else 82 89 0); 83 90 #endif 84 - 85 - if (offset >= len) { 86 - *start = buffer; 87 - *eof = 1; 88 - return 0; 89 - } 90 - *start = buffer + offset; 91 - if ((len -= offset) > count) 92 - return count; 93 - *eof = 1; 94 - 95 - return len; 91 + return 0; 96 92 } 93 + 94 + static int xfs_stat_proc_open(struct inode *inode, struct file *file) 95 + { 96 + return single_open(file, xfs_stat_proc_show, NULL); 97 + } 98 + 99 + static const struct file_operations xfs_stat_proc_fops = { 100 + .owner = THIS_MODULE, 101 + .open = xfs_stat_proc_open, 102 + .read = seq_read, 103 + .llseek = seq_lseek, 104 + .release = single_release, 105 + }; 97 106 98 107 int 99 108 xfs_init_procfs(void) ··· 103 108 if (!proc_mkdir("fs/xfs", NULL)) 104 109 goto out; 105 110 106 - if (!create_proc_read_entry("fs/xfs/stat", 0, NULL, 107 - xfs_read_xfsstats, NULL)) 111 + if (!proc_create("fs/xfs/stat", 0, NULL, 112 + &xfs_stat_proc_fops)) 108 113 goto out_remove_entry; 109 114 return 0; 110 115
+13 -9
fs/xfs/linux-2.6/xfs_super.c
··· 579 579 else if (mp->m_qflags & XFS_UQUOTA_ACCT) 580 580 seq_puts(m, "," MNTOPT_UQUOTANOENF); 581 581 582 - if (mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_OQUOTA_ENFD)) 583 - seq_puts(m, "," MNTOPT_PRJQUOTA); 584 - else if (mp->m_qflags & XFS_PQUOTA_ACCT) 585 - seq_puts(m, "," MNTOPT_PQUOTANOENF); 582 + /* Either project or group quotas can be active, not both */ 586 583 587 - if (mp->m_qflags & (XFS_GQUOTA_ACCT|XFS_OQUOTA_ENFD)) 588 - seq_puts(m, "," MNTOPT_GRPQUOTA); 589 - else if (mp->m_qflags & XFS_GQUOTA_ACCT) 590 - seq_puts(m, "," MNTOPT_GQUOTANOENF); 584 + if (mp->m_qflags & XFS_PQUOTA_ACCT) { 585 + if (mp->m_qflags & XFS_OQUOTA_ENFD) 586 + seq_puts(m, "," MNTOPT_PRJQUOTA); 587 + else 588 + seq_puts(m, "," MNTOPT_PQUOTANOENF); 589 + } else if (mp->m_qflags & XFS_GQUOTA_ACCT) { 590 + if (mp->m_qflags & XFS_OQUOTA_ENFD) 591 + seq_puts(m, "," MNTOPT_GRPQUOTA); 592 + else 593 + seq_puts(m, "," MNTOPT_GQUOTANOENF); 594 + } 591 595 592 596 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT)) 593 597 seq_puts(m, "," MNTOPT_NOQUOTA); ··· 691 687 return error; 692 688 } 693 689 694 - void 690 + STATIC void 695 691 xfs_mountfs_check_barriers(xfs_mount_t *mp) 696 692 { 697 693 int error;
-15
fs/xfs/linux-2.6/xfs_sync.c
··· 749 749 XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG); 750 750 } 751 751 752 - void 753 - xfs_inode_clear_reclaim_tag( 754 - xfs_inode_t *ip) 755 - { 756 - xfs_mount_t *mp = ip->i_mount; 757 - xfs_perag_t *pag = xfs_get_perag(mp, ip->i_ino); 758 - 759 - read_lock(&pag->pag_ici_lock); 760 - spin_lock(&ip->i_flags_lock); 761 - __xfs_inode_clear_reclaim_tag(mp, pag, ip); 762 - spin_unlock(&ip->i_flags_lock); 763 - read_unlock(&pag->pag_ici_lock); 764 - xfs_put_perag(mp, pag); 765 - } 766 - 767 752 STATIC int 768 753 xfs_reclaim_inode_now( 769 754 struct xfs_inode *ip,
-1
fs/xfs/linux-2.6/xfs_sync.h
··· 49 49 50 50 void xfs_inode_set_reclaim_tag(struct xfs_inode *ip); 51 51 void __xfs_inode_set_reclaim_tag(struct xfs_perag *pag, struct xfs_inode *ip); 52 - void xfs_inode_clear_reclaim_tag(struct xfs_inode *ip); 53 52 void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp, struct xfs_perag *pag, 54 53 struct xfs_inode *ip); 55 54
+33 -47
fs/xfs/quota/xfs_qm_stats.c
··· 48 48 49 49 struct xqmstats xqmstats; 50 50 51 - STATIC int 52 - xfs_qm_read_xfsquota( 53 - char *buffer, 54 - char **start, 55 - off_t offset, 56 - int count, 57 - int *eof, 58 - void *data) 51 + static int xqm_proc_show(struct seq_file *m, void *v) 59 52 { 60 - int len; 61 - 62 53 /* maximum; incore; ratio free to inuse; freelist */ 63 - len = sprintf(buffer, "%d\t%d\t%d\t%u\n", 54 + seq_printf(m, "%d\t%d\t%d\t%u\n", 64 55 ndquot, 65 56 xfs_Gqm? atomic_read(&xfs_Gqm->qm_totaldquots) : 0, 66 57 xfs_Gqm? xfs_Gqm->qm_dqfree_ratio : 0, 67 58 xfs_Gqm? xfs_Gqm->qm_dqfreelist.qh_nelems : 0); 68 - 69 - if (offset >= len) { 70 - *start = buffer; 71 - *eof = 1; 72 - return 0; 73 - } 74 - *start = buffer + offset; 75 - if ((len -= offset) > count) 76 - return count; 77 - *eof = 1; 78 - 79 - return len; 59 + return 0; 80 60 } 81 61 82 - STATIC int 83 - xfs_qm_read_stats( 84 - char *buffer, 85 - char **start, 86 - off_t offset, 87 - int count, 88 - int *eof, 89 - void *data) 62 + static int xqm_proc_open(struct inode *inode, struct file *file) 90 63 { 91 - int len; 64 + return single_open(file, xqm_proc_show, NULL); 65 + } 92 66 67 + static const struct file_operations xqm_proc_fops = { 68 + .owner = THIS_MODULE, 69 + .open = xqm_proc_open, 70 + .read = seq_read, 71 + .llseek = seq_lseek, 72 + .release = single_release, 73 + }; 74 + 75 + static int xqmstat_proc_show(struct seq_file *m, void *v) 76 + { 93 77 /* quota performance statistics */ 94 - len = sprintf(buffer, "qm %u %u %u %u %u %u %u %u\n", 78 + seq_printf(m, "qm %u %u %u %u %u %u %u %u\n", 95 79 xqmstats.xs_qm_dqreclaims, 96 80 xqmstats.xs_qm_dqreclaim_misses, 97 81 xqmstats.xs_qm_dquot_dups, ··· 84 100 xqmstats.xs_qm_dqwants, 85 101 xqmstats.xs_qm_dqshake_reclaims, 86 102 xqmstats.xs_qm_dqinact_reclaims); 87 - 88 - if (offset >= len) { 89 - *start = buffer; 90 - *eof = 1; 91 - return 0; 92 - } 93 - *start = buffer + offset; 94 - if ((len -= offset) > count) 95 - return count; 96 - *eof = 1; 97 - 98 - return len; 103 + return 0; 99 104 } 105 + 106 + static int xqmstat_proc_open(struct inode *inode, struct file *file) 107 + { 108 + return single_open(file, xqmstat_proc_show, NULL); 109 + } 110 + 111 + static const struct file_operations xqmstat_proc_fops = { 112 + .owner = THIS_MODULE, 113 + .open = xqmstat_proc_open, 114 + .read = seq_read, 115 + .llseek = seq_lseek, 116 + .release = single_release, 117 + }; 100 118 101 119 void 102 120 xfs_qm_init_procfs(void) 103 121 { 104 - create_proc_read_entry("fs/xfs/xqmstat", 0, NULL, xfs_qm_read_stats, NULL); 105 - create_proc_read_entry("fs/xfs/xqm", 0, NULL, xfs_qm_read_xfsquota, NULL); 122 + proc_create("fs/xfs/xqmstat", 0, NULL, &xqmstat_proc_fops); 123 + proc_create("fs/xfs/xqm", 0, NULL, &xqm_proc_fops); 106 124 } 107 125 108 126 void
+9
fs/xfs/xfs_ag.h
··· 198 198 xfs_agino_t pagi_count; /* number of allocated inodes */ 199 199 int pagb_count; /* pagb slots in use */ 200 200 xfs_perag_busy_t *pagb_list; /* unstable blocks */ 201 + 202 + /* 203 + * Inode allocation search lookup optimisation. 204 + * If the pagino matches, the search for new inodes 205 + * doesn't need to search the near ones again straight away 206 + */ 207 + xfs_agino_t pagl_pagino; 208 + xfs_agino_t pagl_leftrec; 209 + xfs_agino_t pagl_rightrec; 201 210 #ifdef __KERNEL__ 202 211 spinlock_t pagb_lock; /* lock for pagb_list */ 203 212
+1 -1
fs/xfs/xfs_bmap.c
··· 3713 3713 * entry (null if none). Else, *lastxp will be set to the index 3714 3714 * of the found entry; *gotp will contain the entry. 3715 3715 */ 3716 - xfs_bmbt_rec_host_t * /* pointer to found extent entry */ 3716 + STATIC xfs_bmbt_rec_host_t * /* pointer to found extent entry */ 3717 3717 xfs_bmap_search_multi_extents( 3718 3718 xfs_ifork_t *ifp, /* inode fork pointer */ 3719 3719 xfs_fileoff_t bno, /* block number searched for */
-11
fs/xfs/xfs_bmap.h
··· 392 392 int whichfork, 393 393 int *count); 394 394 395 - /* 396 - * Search the extent records for the entry containing block bno. 397 - * If bno lies in a hole, point to the next entry. If bno lies 398 - * past eof, *eofp will be set, and *prevp will contain the last 399 - * entry (null if none). Else, *lastxp will be set to the index 400 - * of the found entry; *gotp will contain the entry. 401 - */ 402 - xfs_bmbt_rec_host_t * 403 - xfs_bmap_search_multi_extents(struct xfs_ifork *, xfs_fileoff_t, int *, 404 - xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *); 405 - 406 395 #endif /* __KERNEL__ */ 407 396 408 397 #endif /* __XFS_BMAP_H__ */
+10 -10
fs/xfs/xfs_bmap_btree.c
··· 202 202 ext_flag); 203 203 } 204 204 205 - /* Endian flipping versions of the bmbt extraction functions */ 206 - void 207 - xfs_bmbt_disk_get_all( 208 - xfs_bmbt_rec_t *r, 209 - xfs_bmbt_irec_t *s) 210 - { 211 - __xfs_bmbt_get_all(get_unaligned_be64(&r->l0), 212 - get_unaligned_be64(&r->l1), s); 213 - } 214 - 215 205 /* 216 206 * Extract the blockcount field from an on disk bmap extent record. 217 207 */ ··· 804 814 { 805 815 *l0 = be64_to_cpu(key->bmbt.br_startoff); 806 816 *l1 = 0; 817 + } 818 + 819 + /* Endian flipping versions of the bmbt extraction functions */ 820 + STATIC void 821 + xfs_bmbt_disk_get_all( 822 + xfs_bmbt_rec_t *r, 823 + xfs_bmbt_irec_t *s) 824 + { 825 + __xfs_bmbt_get_all(get_unaligned_be64(&r->l0), 826 + get_unaligned_be64(&r->l1), s); 807 827 } 808 828 809 829 STATIC void
-1
fs/xfs/xfs_bmap_btree.h
··· 220 220 extern xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_host_t *r); 221 221 extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_host_t *r); 222 222 223 - extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s); 224 223 extern xfs_filblks_t xfs_bmbt_disk_get_blockcount(xfs_bmbt_rec_t *r); 225 224 extern xfs_fileoff_t xfs_bmbt_disk_get_startoff(xfs_bmbt_rec_t *r); 226 225
+1 -41
fs/xfs/xfs_btree.c
··· 646 646 } 647 647 648 648 /* 649 - * Get a buffer for the block, return it read in. 650 - * Short-form addressing. 651 - */ 652 - int /* error */ 653 - xfs_btree_read_bufs( 654 - xfs_mount_t *mp, /* file system mount point */ 655 - xfs_trans_t *tp, /* transaction pointer */ 656 - xfs_agnumber_t agno, /* allocation group number */ 657 - xfs_agblock_t agbno, /* allocation group block number */ 658 - uint lock, /* lock flags for read_buf */ 659 - xfs_buf_t **bpp, /* buffer for agno/agbno */ 660 - int refval) /* ref count value for buffer */ 661 - { 662 - xfs_buf_t *bp; /* return value */ 663 - xfs_daddr_t d; /* real disk block address */ 664 - int error; 665 - 666 - ASSERT(agno != NULLAGNUMBER); 667 - ASSERT(agbno != NULLAGBLOCK); 668 - d = XFS_AGB_TO_DADDR(mp, agno, agbno); 669 - if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, 670 - mp->m_bsize, lock, &bp))) { 671 - return error; 672 - } 673 - ASSERT(!bp || !XFS_BUF_GETERROR(bp)); 674 - if (bp != NULL) { 675 - switch (refval) { 676 - case XFS_ALLOC_BTREE_REF: 677 - XFS_BUF_SET_VTYPE_REF(bp, B_FS_MAP, refval); 678 - break; 679 - case XFS_INO_BTREE_REF: 680 - XFS_BUF_SET_VTYPE_REF(bp, B_FS_INOMAP, refval); 681 - break; 682 - } 683 - } 684 - *bpp = bp; 685 - return 0; 686 - } 687 - 688 - /* 689 649 * Read-ahead the block, don't wait for it, don't return a buffer. 690 650 * Long-form addressing. 691 651 */ ··· 2911 2951 * inode we have to copy the single block it was pointing to into the 2912 2952 * inode. 2913 2953 */ 2914 - int 2954 + STATIC int 2915 2955 xfs_btree_kill_iroot( 2916 2956 struct xfs_btree_cur *cur) 2917 2957 {
-15
fs/xfs/xfs_btree.h
··· 379 379 int refval);/* ref count value for buffer */ 380 380 381 381 /* 382 - * Get a buffer for the block, return it read in. 383 - * Short-form addressing. 384 - */ 385 - int /* error */ 386 - xfs_btree_read_bufs( 387 - struct xfs_mount *mp, /* file system mount point */ 388 - struct xfs_trans *tp, /* transaction pointer */ 389 - xfs_agnumber_t agno, /* allocation group number */ 390 - xfs_agblock_t agbno, /* allocation group block number */ 391 - uint lock, /* lock flags for read_buf */ 392 - struct xfs_buf **bpp, /* buffer for agno/agbno */ 393 - int refval);/* ref count value for buffer */ 394 - 395 - /* 396 382 * Read-ahead the block, don't wait for it, don't return a buffer. 397 383 * Long-form addressing. 398 384 */ ··· 418 432 int xfs_btree_lookup(struct xfs_btree_cur *, xfs_lookup_t, int *); 419 433 int xfs_btree_update(struct xfs_btree_cur *, union xfs_btree_rec *); 420 434 int xfs_btree_new_iroot(struct xfs_btree_cur *, int *, int *); 421 - int xfs_btree_kill_iroot(struct xfs_btree_cur *); 422 435 int xfs_btree_insert(struct xfs_btree_cur *, int *); 423 436 int xfs_btree_delete(struct xfs_btree_cur *, int *); 424 437 int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *);
+410 -403
fs/xfs/xfs_ialloc.c
··· 57 57 } 58 58 59 59 /* 60 - * Lookup the record equal to ino in the btree given by cur. 61 - */ 62 - STATIC int /* error */ 63 - xfs_inobt_lookup_eq( 64 - struct xfs_btree_cur *cur, /* btree cursor */ 65 - xfs_agino_t ino, /* starting inode of chunk */ 66 - __int32_t fcnt, /* free inode count */ 67 - xfs_inofree_t free, /* free inode mask */ 68 - int *stat) /* success/failure */ 69 - { 70 - cur->bc_rec.i.ir_startino = ino; 71 - cur->bc_rec.i.ir_freecount = fcnt; 72 - cur->bc_rec.i.ir_free = free; 73 - return xfs_btree_lookup(cur, XFS_LOOKUP_EQ, stat); 74 - } 75 - 76 - /* 77 - * Lookup the first record greater than or equal to ino 78 - * in the btree given by cur. 60 + * Lookup a record by ino in the btree given by cur. 79 61 */ 80 62 int /* error */ 81 - xfs_inobt_lookup_ge( 63 + xfs_inobt_lookup( 82 64 struct xfs_btree_cur *cur, /* btree cursor */ 83 65 xfs_agino_t ino, /* starting inode of chunk */ 84 - __int32_t fcnt, /* free inode count */ 85 - xfs_inofree_t free, /* free inode mask */ 66 + xfs_lookup_t dir, /* <=, >=, == */ 86 67 int *stat) /* success/failure */ 87 68 { 88 69 cur->bc_rec.i.ir_startino = ino; 89 - cur->bc_rec.i.ir_freecount = fcnt; 90 - cur->bc_rec.i.ir_free = free; 91 - return xfs_btree_lookup(cur, XFS_LOOKUP_GE, stat); 70 + cur->bc_rec.i.ir_freecount = 0; 71 + cur->bc_rec.i.ir_free = 0; 72 + return xfs_btree_lookup(cur, dir, stat); 92 73 } 93 74 94 75 /* 95 - * Lookup the first record less than or equal to ino 96 - * in the btree given by cur. 97 - */ 98 - int /* error */ 99 - xfs_inobt_lookup_le( 100 - struct xfs_btree_cur *cur, /* btree cursor */ 101 - xfs_agino_t ino, /* starting inode of chunk */ 102 - __int32_t fcnt, /* free inode count */ 103 - xfs_inofree_t free, /* free inode mask */ 104 - int *stat) /* success/failure */ 105 - { 106 - cur->bc_rec.i.ir_startino = ino; 107 - cur->bc_rec.i.ir_freecount = fcnt; 108 - cur->bc_rec.i.ir_free = free; 109 - return xfs_btree_lookup(cur, XFS_LOOKUP_LE, stat); 110 - } 111 - 112 - /* 113 - * Update the record referred to by cur to the value given 114 - * by [ino, fcnt, free]. 76 + * Update the record referred to by cur to the value given. 115 77 * This either works (return 0) or gets an EFSCORRUPTED error. 116 78 */ 117 79 STATIC int /* error */ 118 80 xfs_inobt_update( 119 81 struct xfs_btree_cur *cur, /* btree cursor */ 120 - xfs_agino_t ino, /* starting inode of chunk */ 121 - __int32_t fcnt, /* free inode count */ 122 - xfs_inofree_t free) /* free inode mask */ 82 + xfs_inobt_rec_incore_t *irec) /* btree record */ 123 83 { 124 84 union xfs_btree_rec rec; 125 85 126 - rec.inobt.ir_startino = cpu_to_be32(ino); 127 - rec.inobt.ir_freecount = cpu_to_be32(fcnt); 128 - rec.inobt.ir_free = cpu_to_be64(free); 86 + rec.inobt.ir_startino = cpu_to_be32(irec->ir_startino); 87 + rec.inobt.ir_freecount = cpu_to_be32(irec->ir_freecount); 88 + rec.inobt.ir_free = cpu_to_be64(irec->ir_free); 129 89 return xfs_btree_update(cur, &rec); 130 90 } 131 91 ··· 95 135 int /* error */ 96 136 xfs_inobt_get_rec( 97 137 struct xfs_btree_cur *cur, /* btree cursor */ 98 - xfs_agino_t *ino, /* output: starting inode of chunk */ 99 - __int32_t *fcnt, /* output: number of free inodes */ 100 - xfs_inofree_t *free, /* output: free inode mask */ 138 + xfs_inobt_rec_incore_t *irec, /* btree record */ 101 139 int *stat) /* output: success/failure */ 102 140 { 103 141 union xfs_btree_rec *rec; ··· 103 145 104 146 error = xfs_btree_get_rec(cur, &rec, stat); 105 147 if (!error && *stat == 1) { 106 - *ino = be32_to_cpu(rec->inobt.ir_startino); 107 - *fcnt = be32_to_cpu(rec->inobt.ir_freecount); 108 - *free = be64_to_cpu(rec->inobt.ir_free); 148 + irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino); 149 + irec->ir_freecount = be32_to_cpu(rec->inobt.ir_freecount); 150 + irec->ir_free = be64_to_cpu(rec->inobt.ir_free); 109 151 } 110 152 return error; 153 + } 154 + 155 + /* 156 + * Verify that the number of free inodes in the AGI is correct. 157 + */ 158 + #ifdef DEBUG 159 + STATIC int 160 + xfs_check_agi_freecount( 161 + struct xfs_btree_cur *cur, 162 + struct xfs_agi *agi) 163 + { 164 + if (cur->bc_nlevels == 1) { 165 + xfs_inobt_rec_incore_t rec; 166 + int freecount = 0; 167 + int error; 168 + int i; 169 + 170 + error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i); 171 + if (error) 172 + return error; 173 + 174 + do { 175 + error = xfs_inobt_get_rec(cur, &rec, &i); 176 + if (error) 177 + return error; 178 + 179 + if (i) { 180 + freecount += rec.ir_freecount; 181 + error = xfs_btree_increment(cur, 0, &i); 182 + if (error) 183 + return error; 184 + } 185 + } while (i == 1); 186 + 187 + if (!XFS_FORCED_SHUTDOWN(cur->bc_mp)) 188 + ASSERT(freecount == be32_to_cpu(agi->agi_freecount)); 189 + } 190 + return 0; 191 + } 192 + #else 193 + #define xfs_check_agi_freecount(cur, agi) 0 194 + #endif 195 + 196 + /* 197 + * Initialise a new set of inodes. 198 + */ 199 + STATIC void 200 + xfs_ialloc_inode_init( 201 + struct xfs_mount *mp, 202 + struct xfs_trans *tp, 203 + xfs_agnumber_t agno, 204 + xfs_agblock_t agbno, 205 + xfs_agblock_t length, 206 + unsigned int gen) 207 + { 208 + struct xfs_buf *fbuf; 209 + struct xfs_dinode *free; 210 + int blks_per_cluster, nbufs, ninodes; 211 + int version; 212 + int i, j; 213 + xfs_daddr_t d; 214 + 215 + /* 216 + * Loop over the new block(s), filling in the inodes. 217 + * For small block sizes, manipulate the inodes in buffers 218 + * which are multiples of the blocks size. 219 + */ 220 + if (mp->m_sb.sb_blocksize >= XFS_INODE_CLUSTER_SIZE(mp)) { 221 + blks_per_cluster = 1; 222 + nbufs = length; 223 + ninodes = mp->m_sb.sb_inopblock; 224 + } else { 225 + blks_per_cluster = XFS_INODE_CLUSTER_SIZE(mp) / 226 + mp->m_sb.sb_blocksize; 227 + nbufs = length / blks_per_cluster; 228 + ninodes = blks_per_cluster * mp->m_sb.sb_inopblock; 229 + } 230 + 231 + /* 232 + * Figure out what version number to use in the inodes we create. 233 + * If the superblock version has caught up to the one that supports 234 + * the new inode format, then use the new inode version. Otherwise 235 + * use the old version so that old kernels will continue to be 236 + * able to use the file system. 237 + */ 238 + if (xfs_sb_version_hasnlink(&mp->m_sb)) 239 + version = 2; 240 + else 241 + version = 1; 242 + 243 + for (j = 0; j < nbufs; j++) { 244 + /* 245 + * Get the block. 246 + */ 247 + d = XFS_AGB_TO_DADDR(mp, agno, agbno + (j * blks_per_cluster)); 248 + fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 249 + mp->m_bsize * blks_per_cluster, 250 + XFS_BUF_LOCK); 251 + ASSERT(fbuf); 252 + ASSERT(!XFS_BUF_GETERROR(fbuf)); 253 + 254 + /* 255 + * Initialize all inodes in this buffer and then log them. 256 + * 257 + * XXX: It would be much better if we had just one transaction 258 + * to log a whole cluster of inodes instead of all the 259 + * individual transactions causing a lot of log traffic. 260 + */ 261 + xfs_biozero(fbuf, 0, ninodes << mp->m_sb.sb_inodelog); 262 + for (i = 0; i < ninodes; i++) { 263 + int ioffset = i << mp->m_sb.sb_inodelog; 264 + uint isize = sizeof(struct xfs_dinode); 265 + 266 + free = xfs_make_iptr(mp, fbuf, i); 267 + free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); 268 + free->di_version = version; 269 + free->di_gen = cpu_to_be32(gen); 270 + free->di_next_unlinked = cpu_to_be32(NULLAGINO); 271 + xfs_trans_log_buf(tp, fbuf, ioffset, ioffset + isize - 1); 272 + } 273 + xfs_trans_inode_alloc_buf(tp, fbuf); 274 + } 111 275 } 112 276 113 277 /* ··· 244 164 { 245 165 xfs_agi_t *agi; /* allocation group header */ 246 166 xfs_alloc_arg_t args; /* allocation argument structure */ 247 - int blks_per_cluster; /* fs blocks per inode cluster */ 248 167 xfs_btree_cur_t *cur; /* inode btree cursor */ 249 - xfs_daddr_t d; /* disk addr of buffer */ 250 168 xfs_agnumber_t agno; 251 169 int error; 252 - xfs_buf_t *fbuf; /* new free inodes' buffer */ 253 - xfs_dinode_t *free; /* new free inode structure */ 254 - int i; /* inode counter */ 255 - int j; /* block counter */ 256 - int nbufs; /* num bufs of new inodes */ 170 + int i; 257 171 xfs_agino_t newino; /* new first inode's number */ 258 172 xfs_agino_t newlen; /* new number of inodes */ 259 - int ninodes; /* num inodes per buf */ 260 173 xfs_agino_t thisino; /* current inode number, for loop */ 261 - int version; /* inode version number to use */ 262 174 int isaligned = 0; /* inode allocation at stripe unit */ 263 175 /* boundary */ 264 - unsigned int gen; 265 176 266 177 args.tp = tp; 267 178 args.mp = tp->t_mountp; ··· 273 202 */ 274 203 agi = XFS_BUF_TO_AGI(agbp); 275 204 newino = be32_to_cpu(agi->agi_newino); 205 + agno = be32_to_cpu(agi->agi_seqno); 276 206 args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) + 277 207 XFS_IALLOC_BLOCKS(args.mp); 278 208 if (likely(newino != NULLAGINO && 279 209 (args.agbno < be32_to_cpu(agi->agi_length)))) { 280 - args.fsbno = XFS_AGB_TO_FSB(args.mp, 281 - be32_to_cpu(agi->agi_seqno), args.agbno); 210 + args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 282 211 args.type = XFS_ALLOCTYPE_THIS_BNO; 283 212 args.mod = args.total = args.wasdel = args.isfl = 284 213 args.userdata = args.minalignslop = 0; ··· 329 258 * For now, just allocate blocks up front. 330 259 */ 331 260 args.agbno = be32_to_cpu(agi->agi_root); 332 - args.fsbno = XFS_AGB_TO_FSB(args.mp, 333 - be32_to_cpu(agi->agi_seqno), args.agbno); 261 + args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 334 262 /* 335 263 * Allocate a fixed-size extent of inodes. 336 264 */ ··· 352 282 if (isaligned && args.fsbno == NULLFSBLOCK) { 353 283 args.type = XFS_ALLOCTYPE_NEAR_BNO; 354 284 args.agbno = be32_to_cpu(agi->agi_root); 355 - args.fsbno = XFS_AGB_TO_FSB(args.mp, 356 - be32_to_cpu(agi->agi_seqno), args.agbno); 285 + args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 357 286 args.alignment = xfs_ialloc_cluster_alignment(&args); 358 287 if ((error = xfs_alloc_vextent(&args))) 359 288 return error; ··· 363 294 return 0; 364 295 } 365 296 ASSERT(args.len == args.minlen); 366 - /* 367 - * Convert the results. 368 - */ 369 - newino = XFS_OFFBNO_TO_AGINO(args.mp, args.agbno, 0); 370 - /* 371 - * Loop over the new block(s), filling in the inodes. 372 - * For small block sizes, manipulate the inodes in buffers 373 - * which are multiples of the blocks size. 374 - */ 375 - if (args.mp->m_sb.sb_blocksize >= XFS_INODE_CLUSTER_SIZE(args.mp)) { 376 - blks_per_cluster = 1; 377 - nbufs = (int)args.len; 378 - ninodes = args.mp->m_sb.sb_inopblock; 379 - } else { 380 - blks_per_cluster = XFS_INODE_CLUSTER_SIZE(args.mp) / 381 - args.mp->m_sb.sb_blocksize; 382 - nbufs = (int)args.len / blks_per_cluster; 383 - ninodes = blks_per_cluster * args.mp->m_sb.sb_inopblock; 384 - } 385 - /* 386 - * Figure out what version number to use in the inodes we create. 387 - * If the superblock version has caught up to the one that supports 388 - * the new inode format, then use the new inode version. Otherwise 389 - * use the old version so that old kernels will continue to be 390 - * able to use the file system. 391 - */ 392 - if (xfs_sb_version_hasnlink(&args.mp->m_sb)) 393 - version = 2; 394 - else 395 - version = 1; 396 297 397 298 /* 299 + * Stamp and write the inode buffers. 300 + * 398 301 * Seed the new inode cluster with a random generation number. This 399 302 * prevents short-term reuse of generation numbers if a chunk is 400 303 * freed and then immediately reallocated. We use random numbers 401 304 * rather than a linear progression to prevent the next generation 402 305 * number from being easily guessable. 403 306 */ 404 - gen = random32(); 405 - for (j = 0; j < nbufs; j++) { 406 - /* 407 - * Get the block. 408 - */ 409 - d = XFS_AGB_TO_DADDR(args.mp, be32_to_cpu(agi->agi_seqno), 410 - args.agbno + (j * blks_per_cluster)); 411 - fbuf = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, d, 412 - args.mp->m_bsize * blks_per_cluster, 413 - XFS_BUF_LOCK); 414 - ASSERT(fbuf); 415 - ASSERT(!XFS_BUF_GETERROR(fbuf)); 307 + xfs_ialloc_inode_init(args.mp, tp, agno, args.agbno, args.len, 308 + random32()); 416 309 417 - /* 418 - * Initialize all inodes in this buffer and then log them. 419 - * 420 - * XXX: It would be much better if we had just one transaction to 421 - * log a whole cluster of inodes instead of all the individual 422 - * transactions causing a lot of log traffic. 423 - */ 424 - xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog); 425 - for (i = 0; i < ninodes; i++) { 426 - int ioffset = i << args.mp->m_sb.sb_inodelog; 427 - uint isize = sizeof(struct xfs_dinode); 428 - 429 - free = xfs_make_iptr(args.mp, fbuf, i); 430 - free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); 431 - free->di_version = version; 432 - free->di_gen = cpu_to_be32(gen); 433 - free->di_next_unlinked = cpu_to_be32(NULLAGINO); 434 - xfs_trans_log_buf(tp, fbuf, ioffset, ioffset + isize - 1); 435 - } 436 - xfs_trans_inode_alloc_buf(tp, fbuf); 437 - } 310 + /* 311 + * Convert the results. 312 + */ 313 + newino = XFS_OFFBNO_TO_AGINO(args.mp, args.agbno, 0); 438 314 be32_add_cpu(&agi->agi_count, newlen); 439 315 be32_add_cpu(&agi->agi_freecount, newlen); 440 - agno = be32_to_cpu(agi->agi_seqno); 441 316 down_read(&args.mp->m_peraglock); 442 317 args.mp->m_perag[agno].pagi_freecount += newlen; 443 318 up_read(&args.mp->m_peraglock); 444 319 agi->agi_newino = cpu_to_be32(newino); 320 + 445 321 /* 446 322 * Insert records describing the new inode chunk into the btree. 447 323 */ ··· 394 380 for (thisino = newino; 395 381 thisino < newino + newlen; 396 382 thisino += XFS_INODES_PER_CHUNK) { 397 - if ((error = xfs_inobt_lookup_eq(cur, thisino, 398 - XFS_INODES_PER_CHUNK, XFS_INOBT_ALL_FREE, &i))) { 383 + cur->bc_rec.i.ir_startino = thisino; 384 + cur->bc_rec.i.ir_freecount = XFS_INODES_PER_CHUNK; 385 + cur->bc_rec.i.ir_free = XFS_INOBT_ALL_FREE; 386 + error = xfs_btree_lookup(cur, XFS_LOOKUP_EQ, &i); 387 + if (error) { 399 388 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); 400 389 return error; 401 390 } 402 391 ASSERT(i == 0); 403 - if ((error = xfs_btree_insert(cur, &i))) { 392 + error = xfs_btree_insert(cur, &i); 393 + if (error) { 404 394 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); 405 395 return error; 406 396 } ··· 557 539 } 558 540 559 541 /* 542 + * Try to retrieve the next record to the left/right from the current one. 543 + */ 544 + STATIC int 545 + xfs_ialloc_next_rec( 546 + struct xfs_btree_cur *cur, 547 + xfs_inobt_rec_incore_t *rec, 548 + int *done, 549 + int left) 550 + { 551 + int error; 552 + int i; 553 + 554 + if (left) 555 + error = xfs_btree_decrement(cur, 0, &i); 556 + else 557 + error = xfs_btree_increment(cur, 0, &i); 558 + 559 + if (error) 560 + return error; 561 + *done = !i; 562 + if (i) { 563 + error = xfs_inobt_get_rec(cur, rec, &i); 564 + if (error) 565 + return error; 566 + XFS_WANT_CORRUPTED_RETURN(i == 1); 567 + } 568 + 569 + return 0; 570 + } 571 + 572 + STATIC int 573 + xfs_ialloc_get_rec( 574 + struct xfs_btree_cur *cur, 575 + xfs_agino_t agino, 576 + xfs_inobt_rec_incore_t *rec, 577 + int *done, 578 + int left) 579 + { 580 + int error; 581 + int i; 582 + 583 + error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_EQ, &i); 584 + if (error) 585 + return error; 586 + *done = !i; 587 + if (i) { 588 + error = xfs_inobt_get_rec(cur, rec, &i); 589 + if (error) 590 + return error; 591 + XFS_WANT_CORRUPTED_RETURN(i == 1); 592 + } 593 + 594 + return 0; 595 + } 596 + 597 + /* 560 598 * Visible inode allocation functions. 561 599 */ 562 600 ··· 666 592 int j; /* result code */ 667 593 xfs_mount_t *mp; /* file system mount structure */ 668 594 int offset; /* index of inode in chunk */ 669 - xfs_agino_t pagino; /* parent's a.g. relative inode # */ 670 - xfs_agnumber_t pagno; /* parent's allocation group number */ 595 + xfs_agino_t pagino; /* parent's AG relative inode # */ 596 + xfs_agnumber_t pagno; /* parent's AG number */ 671 597 xfs_inobt_rec_incore_t rec; /* inode allocation record */ 672 598 xfs_agnumber_t tagno; /* testing allocation group number */ 673 599 xfs_btree_cur_t *tcur; /* temp cursor */ ··· 790 716 */ 791 717 agno = tagno; 792 718 *IO_agbp = NULL; 719 + 720 + restart_pagno: 793 721 cur = xfs_inobt_init_cursor(mp, tp, agbp, be32_to_cpu(agi->agi_seqno)); 794 722 /* 795 723 * If pagino is 0 (this is the root inode allocation) use newino. ··· 799 723 */ 800 724 if (!pagino) 801 725 pagino = be32_to_cpu(agi->agi_newino); 802 - #ifdef DEBUG 803 - if (cur->bc_nlevels == 1) { 804 - int freecount = 0; 805 726 806 - if ((error = xfs_inobt_lookup_ge(cur, 0, 0, 0, &i))) 807 - goto error0; 808 - XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 809 - do { 810 - if ((error = xfs_inobt_get_rec(cur, &rec.ir_startino, 811 - &rec.ir_freecount, &rec.ir_free, &i))) 812 - goto error0; 813 - XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 814 - freecount += rec.ir_freecount; 815 - if ((error = xfs_btree_increment(cur, 0, &i))) 816 - goto error0; 817 - } while (i == 1); 727 + error = xfs_check_agi_freecount(cur, agi); 728 + if (error) 729 + goto error0; 818 730 819 - ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || 820 - XFS_FORCED_SHUTDOWN(mp)); 821 - } 822 - #endif 823 731 /* 824 - * If in the same a.g. as the parent, try to get near the parent. 732 + * If in the same AG as the parent, try to get near the parent. 825 733 */ 826 734 if (pagno == agno) { 827 - if ((error = xfs_inobt_lookup_le(cur, pagino, 0, 0, &i))) 735 + xfs_perag_t *pag = &mp->m_perag[agno]; 736 + int doneleft; /* done, to the left */ 737 + int doneright; /* done, to the right */ 738 + int searchdistance = 10; 739 + 740 + error = xfs_inobt_lookup(cur, pagino, XFS_LOOKUP_LE, &i); 741 + if (error) 828 742 goto error0; 829 - if (i != 0 && 830 - (error = xfs_inobt_get_rec(cur, &rec.ir_startino, 831 - &rec.ir_freecount, &rec.ir_free, &j)) == 0 && 832 - j == 1 && 833 - rec.ir_freecount > 0) { 743 + XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 744 + 745 + error = xfs_inobt_get_rec(cur, &rec, &j); 746 + if (error) 747 + goto error0; 748 + XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 749 + 750 + if (rec.ir_freecount > 0) { 834 751 /* 835 752 * Found a free inode in the same chunk 836 - * as parent, done. 753 + * as the parent, done. 837 754 */ 755 + goto alloc_inode; 838 756 } 757 + 758 + 839 759 /* 840 - * In the same a.g. as parent, but parent's chunk is full. 760 + * In the same AG as parent, but parent's chunk is full. 841 761 */ 842 - else { 843 - int doneleft; /* done, to the left */ 844 - int doneright; /* done, to the right */ 845 762 763 + /* duplicate the cursor, search left & right simultaneously */ 764 + error = xfs_btree_dup_cursor(cur, &tcur); 765 + if (error) 766 + goto error0; 767 + 768 + /* 769 + * Skip to last blocks looked up if same parent inode. 770 + */ 771 + if (pagino != NULLAGINO && 772 + pag->pagl_pagino == pagino && 773 + pag->pagl_leftrec != NULLAGINO && 774 + pag->pagl_rightrec != NULLAGINO) { 775 + error = xfs_ialloc_get_rec(tcur, pag->pagl_leftrec, 776 + &trec, &doneleft, 1); 846 777 if (error) 847 - goto error0; 848 - ASSERT(i == 1); 849 - ASSERT(j == 1); 850 - /* 851 - * Duplicate the cursor, search left & right 852 - * simultaneously. 853 - */ 854 - if ((error = xfs_btree_dup_cursor(cur, &tcur))) 855 - goto error0; 856 - /* 857 - * Search left with tcur, back up 1 record. 858 - */ 859 - if ((error = xfs_btree_decrement(tcur, 0, &i))) 860 778 goto error1; 861 - doneleft = !i; 862 - if (!doneleft) { 863 - if ((error = xfs_inobt_get_rec(tcur, 864 - &trec.ir_startino, 865 - &trec.ir_freecount, 866 - &trec.ir_free, &i))) 867 - goto error1; 868 - XFS_WANT_CORRUPTED_GOTO(i == 1, error1); 869 - } 870 - /* 871 - * Search right with cur, go forward 1 record. 872 - */ 873 - if ((error = xfs_btree_increment(cur, 0, &i))) 874 - goto error1; 875 - doneright = !i; 876 - if (!doneright) { 877 - if ((error = xfs_inobt_get_rec(cur, 878 - &rec.ir_startino, 879 - &rec.ir_freecount, 880 - &rec.ir_free, &i))) 881 - goto error1; 882 - XFS_WANT_CORRUPTED_GOTO(i == 1, error1); 883 - } 884 - /* 885 - * Loop until we find the closest inode chunk 886 - * with a free one. 887 - */ 888 - while (!doneleft || !doneright) { 889 - int useleft; /* using left inode 890 - chunk this time */ 891 779 892 - /* 893 - * Figure out which block is closer, 894 - * if both are valid. 895 - */ 896 - if (!doneleft && !doneright) 897 - useleft = 898 - pagino - 899 - (trec.ir_startino + 900 - XFS_INODES_PER_CHUNK - 1) < 901 - rec.ir_startino - pagino; 902 - else 903 - useleft = !doneleft; 904 - /* 905 - * If checking the left, does it have 906 - * free inodes? 907 - */ 908 - if (useleft && trec.ir_freecount) { 909 - /* 910 - * Yes, set it up as the chunk to use. 911 - */ 912 - rec = trec; 913 - xfs_btree_del_cursor(cur, 914 - XFS_BTREE_NOERROR); 915 - cur = tcur; 916 - break; 917 - } 918 - /* 919 - * If checking the right, does it have 920 - * free inodes? 921 - */ 922 - if (!useleft && rec.ir_freecount) { 923 - /* 924 - * Yes, it's already set up. 925 - */ 926 - xfs_btree_del_cursor(tcur, 927 - XFS_BTREE_NOERROR); 928 - break; 929 - } 930 - /* 931 - * If used the left, get another one 932 - * further left. 933 - */ 934 - if (useleft) { 935 - if ((error = xfs_btree_decrement(tcur, 0, 936 - &i))) 937 - goto error1; 938 - doneleft = !i; 939 - if (!doneleft) { 940 - if ((error = xfs_inobt_get_rec( 941 - tcur, 942 - &trec.ir_startino, 943 - &trec.ir_freecount, 944 - &trec.ir_free, &i))) 945 - goto error1; 946 - XFS_WANT_CORRUPTED_GOTO(i == 1, 947 - error1); 948 - } 949 - } 950 - /* 951 - * If used the right, get another one 952 - * further right. 953 - */ 954 - else { 955 - if ((error = xfs_btree_increment(cur, 0, 956 - &i))) 957 - goto error1; 958 - doneright = !i; 959 - if (!doneright) { 960 - if ((error = xfs_inobt_get_rec( 961 - cur, 962 - &rec.ir_startino, 963 - &rec.ir_freecount, 964 - &rec.ir_free, &i))) 965 - goto error1; 966 - XFS_WANT_CORRUPTED_GOTO(i == 1, 967 - error1); 968 - } 969 - } 970 - } 971 - ASSERT(!doneleft || !doneright); 780 + error = xfs_ialloc_get_rec(cur, pag->pagl_rightrec, 781 + &rec, &doneright, 0); 782 + if (error) 783 + goto error1; 784 + } else { 785 + /* search left with tcur, back up 1 record */ 786 + error = xfs_ialloc_next_rec(tcur, &trec, &doneleft, 1); 787 + if (error) 788 + goto error1; 789 + 790 + /* search right with cur, go forward 1 record. */ 791 + error = xfs_ialloc_next_rec(cur, &rec, &doneright, 0); 792 + if (error) 793 + goto error1; 972 794 } 795 + 796 + /* 797 + * Loop until we find an inode chunk with a free inode. 798 + */ 799 + while (!doneleft || !doneright) { 800 + int useleft; /* using left inode chunk this time */ 801 + 802 + if (!--searchdistance) { 803 + /* 804 + * Not in range - save last search 805 + * location and allocate a new inode 806 + */ 807 + pag->pagl_leftrec = trec.ir_startino; 808 + pag->pagl_rightrec = rec.ir_startino; 809 + pag->pagl_pagino = pagino; 810 + goto newino; 811 + } 812 + 813 + /* figure out the closer block if both are valid. */ 814 + if (!doneleft && !doneright) { 815 + useleft = pagino - 816 + (trec.ir_startino + XFS_INODES_PER_CHUNK - 1) < 817 + rec.ir_startino - pagino; 818 + } else { 819 + useleft = !doneleft; 820 + } 821 + 822 + /* free inodes to the left? */ 823 + if (useleft && trec.ir_freecount) { 824 + rec = trec; 825 + xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 826 + cur = tcur; 827 + 828 + pag->pagl_leftrec = trec.ir_startino; 829 + pag->pagl_rightrec = rec.ir_startino; 830 + pag->pagl_pagino = pagino; 831 + goto alloc_inode; 832 + } 833 + 834 + /* free inodes to the right? */ 835 + if (!useleft && rec.ir_freecount) { 836 + xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); 837 + 838 + pag->pagl_leftrec = trec.ir_startino; 839 + pag->pagl_rightrec = rec.ir_startino; 840 + pag->pagl_pagino = pagino; 841 + goto alloc_inode; 842 + } 843 + 844 + /* get next record to check */ 845 + if (useleft) { 846 + error = xfs_ialloc_next_rec(tcur, &trec, 847 + &doneleft, 1); 848 + } else { 849 + error = xfs_ialloc_next_rec(cur, &rec, 850 + &doneright, 0); 851 + } 852 + if (error) 853 + goto error1; 854 + } 855 + 856 + /* 857 + * We've reached the end of the btree. because 858 + * we are only searching a small chunk of the 859 + * btree each search, there is obviously free 860 + * inodes closer to the parent inode than we 861 + * are now. restart the search again. 862 + */ 863 + pag->pagl_pagino = NULLAGINO; 864 + pag->pagl_leftrec = NULLAGINO; 865 + pag->pagl_rightrec = NULLAGINO; 866 + xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); 867 + xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 868 + goto restart_pagno; 973 869 } 870 + 974 871 /* 975 - * In a different a.g. from the parent. 872 + * In a different AG from the parent. 976 873 * See if the most recently allocated block has any free. 977 874 */ 978 - else if (be32_to_cpu(agi->agi_newino) != NULLAGINO) { 979 - if ((error = xfs_inobt_lookup_eq(cur, 980 - be32_to_cpu(agi->agi_newino), 0, 0, &i))) 875 + newino: 876 + if (be32_to_cpu(agi->agi_newino) != NULLAGINO) { 877 + error = xfs_inobt_lookup(cur, be32_to_cpu(agi->agi_newino), 878 + XFS_LOOKUP_EQ, &i); 879 + if (error) 981 880 goto error0; 982 - if (i == 1 && 983 - (error = xfs_inobt_get_rec(cur, &rec.ir_startino, 984 - &rec.ir_freecount, &rec.ir_free, &j)) == 0 && 985 - j == 1 && 986 - rec.ir_freecount > 0) { 987 - /* 988 - * The last chunk allocated in the group still has 989 - * a free inode. 990 - */ 991 - } 992 - /* 993 - * None left in the last group, search the whole a.g. 994 - */ 995 - else { 881 + 882 + if (i == 1) { 883 + error = xfs_inobt_get_rec(cur, &rec, &j); 996 884 if (error) 997 885 goto error0; 998 - if ((error = xfs_inobt_lookup_ge(cur, 0, 0, 0, &i))) 999 - goto error0; 1000 - ASSERT(i == 1); 1001 - for (;;) { 1002 - if ((error = xfs_inobt_get_rec(cur, 1003 - &rec.ir_startino, 1004 - &rec.ir_freecount, &rec.ir_free, 1005 - &i))) 1006 - goto error0; 1007 - XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1008 - if (rec.ir_freecount > 0) 1009 - break; 1010 - if ((error = xfs_btree_increment(cur, 0, &i))) 1011 - goto error0; 1012 - XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 886 + 887 + if (j == 1 && rec.ir_freecount > 0) { 888 + /* 889 + * The last chunk allocated in the group 890 + * still has a free inode. 891 + */ 892 + goto alloc_inode; 1013 893 } 1014 894 } 1015 895 } 896 + 897 + /* 898 + * None left in the last group, search the whole AG 899 + */ 900 + error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i); 901 + if (error) 902 + goto error0; 903 + XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 904 + 905 + for (;;) { 906 + error = xfs_inobt_get_rec(cur, &rec, &i); 907 + if (error) 908 + goto error0; 909 + XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 910 + if (rec.ir_freecount > 0) 911 + break; 912 + error = xfs_btree_increment(cur, 0, &i); 913 + if (error) 914 + goto error0; 915 + XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 916 + } 917 + 918 + alloc_inode: 1016 919 offset = xfs_ialloc_find_free(&rec.ir_free); 1017 920 ASSERT(offset >= 0); 1018 921 ASSERT(offset < XFS_INODES_PER_CHUNK); ··· 1000 945 ino = XFS_AGINO_TO_INO(mp, agno, rec.ir_startino + offset); 1001 946 rec.ir_free &= ~XFS_INOBT_MASK(offset); 1002 947 rec.ir_freecount--; 1003 - if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount, 1004 - rec.ir_free))) 948 + error = xfs_inobt_update(cur, &rec); 949 + if (error) 1005 950 goto error0; 1006 951 be32_add_cpu(&agi->agi_freecount, -1); 1007 952 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); 1008 953 down_read(&mp->m_peraglock); 1009 954 mp->m_perag[tagno].pagi_freecount--; 1010 955 up_read(&mp->m_peraglock); 1011 - #ifdef DEBUG 1012 - if (cur->bc_nlevels == 1) { 1013 - int freecount = 0; 1014 956 1015 - if ((error = xfs_inobt_lookup_ge(cur, 0, 0, 0, &i))) 1016 - goto error0; 1017 - do { 1018 - if ((error = xfs_inobt_get_rec(cur, &rec.ir_startino, 1019 - &rec.ir_freecount, &rec.ir_free, &i))) 1020 - goto error0; 1021 - XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1022 - freecount += rec.ir_freecount; 1023 - if ((error = xfs_btree_increment(cur, 0, &i))) 1024 - goto error0; 1025 - } while (i == 1); 1026 - ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || 1027 - XFS_FORCED_SHUTDOWN(mp)); 1028 - } 1029 - #endif 957 + error = xfs_check_agi_freecount(cur, agi); 958 + if (error) 959 + goto error0; 960 + 1030 961 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 1031 962 xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -1); 1032 963 *inop = ino; ··· 1103 1062 * Initialize the cursor. 1104 1063 */ 1105 1064 cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); 1106 - #ifdef DEBUG 1107 - if (cur->bc_nlevels == 1) { 1108 - int freecount = 0; 1109 1065 1110 - if ((error = xfs_inobt_lookup_ge(cur, 0, 0, 0, &i))) 1111 - goto error0; 1112 - do { 1113 - if ((error = xfs_inobt_get_rec(cur, &rec.ir_startino, 1114 - &rec.ir_freecount, &rec.ir_free, &i))) 1115 - goto error0; 1116 - if (i) { 1117 - freecount += rec.ir_freecount; 1118 - if ((error = xfs_btree_increment(cur, 0, &i))) 1119 - goto error0; 1120 - } 1121 - } while (i == 1); 1122 - ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || 1123 - XFS_FORCED_SHUTDOWN(mp)); 1124 - } 1125 - #endif 1066 + error = xfs_check_agi_freecount(cur, agi); 1067 + if (error) 1068 + goto error0; 1069 + 1126 1070 /* 1127 1071 * Look for the entry describing this inode. 1128 1072 */ 1129 - if ((error = xfs_inobt_lookup_le(cur, agino, 0, 0, &i))) { 1073 + if ((error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i))) { 1130 1074 cmn_err(CE_WARN, 1131 - "xfs_difree: xfs_inobt_lookup_le returned() an error %d on %s. Returning error.", 1075 + "xfs_difree: xfs_inobt_lookup returned() an error %d on %s. Returning error.", 1132 1076 error, mp->m_fsname); 1133 1077 goto error0; 1134 1078 } 1135 1079 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 1136 - if ((error = xfs_inobt_get_rec(cur, &rec.ir_startino, &rec.ir_freecount, 1137 - &rec.ir_free, &i))) { 1080 + error = xfs_inobt_get_rec(cur, &rec, &i); 1081 + if (error) { 1138 1082 cmn_err(CE_WARN, 1139 1083 "xfs_difree: xfs_inobt_get_rec() returned an error %d on %s. Returning error.", 1140 1084 error, mp->m_fsname); ··· 1174 1148 } else { 1175 1149 *delete = 0; 1176 1150 1177 - if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount, rec.ir_free))) { 1151 + error = xfs_inobt_update(cur, &rec); 1152 + if (error) { 1178 1153 cmn_err(CE_WARN, 1179 - "xfs_difree: xfs_inobt_update() returned an error %d on %s. Returning error.", 1154 + "xfs_difree: xfs_inobt_update returned an error %d on %s.", 1180 1155 error, mp->m_fsname); 1181 1156 goto error0; 1182 1157 } 1158 + 1183 1159 /* 1184 1160 * Change the inode free counts and log the ag/sb changes. 1185 1161 */ ··· 1193 1165 xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, 1); 1194 1166 } 1195 1167 1196 - #ifdef DEBUG 1197 - if (cur->bc_nlevels == 1) { 1198 - int freecount = 0; 1168 + error = xfs_check_agi_freecount(cur, agi); 1169 + if (error) 1170 + goto error0; 1199 1171 1200 - if ((error = xfs_inobt_lookup_ge(cur, 0, 0, 0, &i))) 1201 - goto error0; 1202 - do { 1203 - if ((error = xfs_inobt_get_rec(cur, 1204 - &rec.ir_startino, 1205 - &rec.ir_freecount, 1206 - &rec.ir_free, &i))) 1207 - goto error0; 1208 - if (i) { 1209 - freecount += rec.ir_freecount; 1210 - if ((error = xfs_btree_increment(cur, 0, &i))) 1211 - goto error0; 1212 - } 1213 - } while (i == 1); 1214 - ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || 1215 - XFS_FORCED_SHUTDOWN(mp)); 1216 - } 1217 - #endif 1218 1172 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 1219 1173 return 0; 1220 1174 ··· 1307 1297 chunk_agbno = agbno - offset_agbno; 1308 1298 } else { 1309 1299 xfs_btree_cur_t *cur; /* inode btree cursor */ 1310 - xfs_agino_t chunk_agino; /* first agino in inode chunk */ 1311 - __int32_t chunk_cnt; /* count of free inodes in chunk */ 1312 - xfs_inofree_t chunk_free; /* mask of free inodes in chunk */ 1300 + xfs_inobt_rec_incore_t chunk_rec; 1313 1301 xfs_buf_t *agbp; /* agi buffer */ 1314 1302 int i; /* temp state */ 1315 1303 ··· 1323 1315 } 1324 1316 1325 1317 cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); 1326 - error = xfs_inobt_lookup_le(cur, agino, 0, 0, &i); 1318 + error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, &i); 1327 1319 if (error) { 1328 1320 xfs_fs_cmn_err(CE_ALERT, mp, "xfs_imap: " 1329 - "xfs_inobt_lookup_le() failed"); 1321 + "xfs_inobt_lookup() failed"); 1330 1322 goto error0; 1331 1323 } 1332 1324 1333 - error = xfs_inobt_get_rec(cur, &chunk_agino, &chunk_cnt, 1334 - &chunk_free, &i); 1325 + error = xfs_inobt_get_rec(cur, &chunk_rec, &i); 1335 1326 if (error) { 1336 1327 xfs_fs_cmn_err(CE_ALERT, mp, "xfs_imap: " 1337 1328 "xfs_inobt_get_rec() failed"); ··· 1348 1341 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 1349 1342 if (error) 1350 1343 return error; 1351 - chunk_agbno = XFS_AGINO_TO_AGBNO(mp, chunk_agino); 1344 + chunk_agbno = XFS_AGINO_TO_AGBNO(mp, chunk_rec.ir_startino); 1352 1345 offset_agbno = agbno - chunk_agbno; 1353 1346 } 1354 1347
+5 -13
fs/xfs/xfs_ialloc.h
··· 150 150 xfs_agnumber_t agno); /* allocation group number */ 151 151 152 152 /* 153 - * Lookup the first record greater than or equal to ino 154 - * in the btree given by cur. 153 + * Lookup a record by ino in the btree given by cur. 155 154 */ 156 - int xfs_inobt_lookup_ge(struct xfs_btree_cur *cur, xfs_agino_t ino, 157 - __int32_t fcnt, xfs_inofree_t free, int *stat); 158 - 159 - /* 160 - * Lookup the first record less than or equal to ino 161 - * in the btree given by cur. 162 - */ 163 - int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino, 164 - __int32_t fcnt, xfs_inofree_t free, int *stat); 155 + int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino, 156 + xfs_lookup_t dir, int *stat); 165 157 166 158 /* 167 159 * Get the data from the pointed-to record. 168 160 */ 169 - extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino, 170 - __int32_t *fcnt, xfs_inofree_t *free, int *stat); 161 + extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, 162 + xfs_inobt_rec_incore_t *rec, int *stat); 171 163 172 164 #endif /* __XFS_IALLOC_H__ */
-27
fs/xfs/xfs_iget.c
··· 82 82 memset(&ip->i_df, 0, sizeof(xfs_ifork_t)); 83 83 ip->i_flags = 0; 84 84 ip->i_update_core = 0; 85 - ip->i_update_size = 0; 86 85 ip->i_delayed_blks = 0; 87 86 memset(&ip->i_d, 0, sizeof(xfs_icdinode_t)); 88 87 ip->i_size = 0; ··· 453 454 } 454 455 xfs_put_perag(mp, pag); 455 456 return error; 456 - } 457 - 458 - 459 - /* 460 - * Look for the inode corresponding to the given ino in the hash table. 461 - * If it is there and its i_transp pointer matches tp, return it. 462 - * Otherwise, return NULL. 463 - */ 464 - xfs_inode_t * 465 - xfs_inode_incore(xfs_mount_t *mp, 466 - xfs_ino_t ino, 467 - xfs_trans_t *tp) 468 - { 469 - xfs_inode_t *ip; 470 - xfs_perag_t *pag; 471 - 472 - pag = xfs_get_perag(mp, ino); 473 - read_lock(&pag->pag_ici_lock); 474 - ip = radix_tree_lookup(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ino)); 475 - read_unlock(&pag->pag_ici_lock); 476 - xfs_put_perag(mp, pag); 477 - 478 - /* the returned inode must match the transaction */ 479 - if (ip && (ip->i_transp != tp)) 480 - return NULL; 481 - return ip; 482 457 } 483 458 484 459 /*
+4 -4
fs/xfs/xfs_inode.c
··· 651 651 return 0; 652 652 } 653 653 654 - void 654 + STATIC void 655 655 xfs_dinode_from_disk( 656 656 xfs_icdinode_t *to, 657 657 xfs_dinode_t *from) ··· 1247 1247 * In that case the pages will still be in memory, but the inode size 1248 1248 * will never have been updated. 1249 1249 */ 1250 - xfs_fsize_t 1250 + STATIC xfs_fsize_t 1251 1251 xfs_file_last_byte( 1252 1252 xfs_inode_t *ip) 1253 1253 { ··· 3837 3837 /* 3838 3838 * Resize an extent indirection array to new_size bytes. 3839 3839 */ 3840 - void 3840 + STATIC void 3841 3841 xfs_iext_realloc_indirect( 3842 3842 xfs_ifork_t *ifp, /* inode fork pointer */ 3843 3843 int new_size) /* new indirection array size */ ··· 3862 3862 /* 3863 3863 * Switch from indirection array to linear (direct) extent allocations. 3864 3864 */ 3865 - void 3865 + STATIC void 3866 3866 xfs_iext_indirect_to_direct( 3867 3867 xfs_ifork_t *ifp) /* inode fork pointer */ 3868 3868 {
-8
fs/xfs/xfs_inode.h
··· 261 261 /* Miscellaneous state. */ 262 262 unsigned short i_flags; /* see defined flags below */ 263 263 unsigned char i_update_core; /* timestamps/size is dirty */ 264 - unsigned char i_update_size; /* di_size field is dirty */ 265 264 unsigned int i_delayed_blks; /* count of delay alloc blks */ 266 265 267 266 xfs_icdinode_t i_d; /* most of ondisk inode */ ··· 467 468 /* 468 469 * xfs_iget.c prototypes. 469 470 */ 470 - xfs_inode_t *xfs_inode_incore(struct xfs_mount *, xfs_ino_t, 471 - struct xfs_trans *); 472 471 int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, 473 472 uint, uint, xfs_inode_t **, xfs_daddr_t); 474 473 void xfs_iput(xfs_inode_t *, uint); ··· 501 504 void xfs_iunpin(xfs_inode_t *); 502 505 int xfs_iflush(xfs_inode_t *, uint); 503 506 void xfs_ichgtime(xfs_inode_t *, int); 504 - xfs_fsize_t xfs_file_last_byte(xfs_inode_t *); 505 507 void xfs_lock_inodes(xfs_inode_t **, int, uint); 506 508 void xfs_lock_two_inodes(xfs_inode_t *, xfs_inode_t *, uint); 507 509 ··· 568 572 struct xfs_buf **, uint); 569 573 int xfs_iread(struct xfs_mount *, struct xfs_trans *, 570 574 struct xfs_inode *, xfs_daddr_t, uint); 571 - void xfs_dinode_from_disk(struct xfs_icdinode *, 572 - struct xfs_dinode *); 573 575 void xfs_dinode_to_disk(struct xfs_dinode *, 574 576 struct xfs_icdinode *); 575 577 void xfs_idestroy_fork(struct xfs_inode *, int); ··· 586 592 void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int); 587 593 void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int); 588 594 void xfs_iext_realloc_direct(xfs_ifork_t *, int); 589 - void xfs_iext_realloc_indirect(xfs_ifork_t *, int); 590 - void xfs_iext_indirect_to_direct(xfs_ifork_t *); 591 595 void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t); 592 596 void xfs_iext_inline_to_direct(xfs_ifork_t *, int); 593 597 void xfs_iext_destroy(xfs_ifork_t *);
-10
fs/xfs/xfs_inode_item.c
··· 263 263 } 264 264 265 265 /* 266 - * We don't have to worry about re-ordering here because 267 - * the update_size field is protected by the inode lock 268 - * and we have that held in exclusive mode. 269 - */ 270 - if (ip->i_update_size) 271 - ip->i_update_size = 0; 272 - 273 - /* 274 266 * Make sure to get the latest atime from the Linux inode. 275 267 */ 276 268 xfs_synchronize_atime(ip); ··· 704 712 * Clear out the fields of the inode log item particular 705 713 * to the current transaction. 706 714 */ 707 - iip->ili_ilock_recur = 0; 708 - iip->ili_iolock_recur = 0; 709 715 iip->ili_flags = 0; 710 716 711 717 /*
-2
fs/xfs/xfs_inode_item.h
··· 137 137 struct xfs_inode *ili_inode; /* inode ptr */ 138 138 xfs_lsn_t ili_flush_lsn; /* lsn at last flush */ 139 139 xfs_lsn_t ili_last_lsn; /* lsn at last transaction */ 140 - unsigned short ili_ilock_recur; /* lock recursion count */ 141 - unsigned short ili_iolock_recur; /* lock recursion count */ 142 140 unsigned short ili_flags; /* misc flags */ 143 141 unsigned short ili_logged; /* flushed logged data */ 144 142 unsigned int ili_last_fields; /* fields when flushed */
-1
fs/xfs/xfs_inum.h
··· 72 72 73 73 #if XFS_BIG_INUMS 74 74 #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) 75 - #define XFS_INO64_OFFSET ((xfs_ino_t)(1ULL << 32)) 76 75 #else 77 76 #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 32) - 1ULL)) 78 77 #endif
+52 -46
fs/xfs/xfs_itable.c
··· 39 39 #include "xfs_error.h" 40 40 #include "xfs_btree.h" 41 41 42 - int 42 + STATIC int 43 43 xfs_internal_inum( 44 44 xfs_mount_t *mp, 45 45 xfs_ino_t ino) ··· 353 353 int end_of_ag; /* set if we've seen the ag end */ 354 354 int error; /* error code */ 355 355 int fmterror;/* bulkstat formatter result */ 356 - __int32_t gcnt; /* current btree rec's count */ 357 - xfs_inofree_t gfree; /* current btree rec's free mask */ 358 - xfs_agino_t gino; /* current btree rec's start inode */ 359 356 int i; /* loop index */ 360 357 int icount; /* count of inodes good in irbuf */ 361 358 size_t irbsize; /* size of irec buffer in bytes */ ··· 439 442 * we need to get the remainder of the chunk we're in. 440 443 */ 441 444 if (agino > 0) { 445 + xfs_inobt_rec_incore_t r; 446 + 442 447 /* 443 448 * Lookup the inode chunk that this inode lives in. 444 449 */ 445 - error = xfs_inobt_lookup_le(cur, agino, 0, 0, &tmp); 450 + error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_LE, 451 + &tmp); 446 452 if (!error && /* no I/O error */ 447 453 tmp && /* lookup succeeded */ 448 454 /* got the record, should always work */ 449 - !(error = xfs_inobt_get_rec(cur, &gino, &gcnt, 450 - &gfree, &i)) && 455 + !(error = xfs_inobt_get_rec(cur, &r, &i)) && 451 456 i == 1 && 452 457 /* this is the right chunk */ 453 - agino < gino + XFS_INODES_PER_CHUNK && 458 + agino < r.ir_startino + XFS_INODES_PER_CHUNK && 454 459 /* lastino was not last in chunk */ 455 - (chunkidx = agino - gino + 1) < 460 + (chunkidx = agino - r.ir_startino + 1) < 456 461 XFS_INODES_PER_CHUNK && 457 462 /* there are some left allocated */ 458 463 xfs_inobt_maskn(chunkidx, 459 - XFS_INODES_PER_CHUNK - chunkidx) & ~gfree) { 464 + XFS_INODES_PER_CHUNK - chunkidx) & 465 + ~r.ir_free) { 460 466 /* 461 467 * Grab the chunk record. Mark all the 462 468 * uninteresting inodes (because they're 463 469 * before our start point) free. 464 470 */ 465 471 for (i = 0; i < chunkidx; i++) { 466 - if (XFS_INOBT_MASK(i) & ~gfree) 467 - gcnt++; 472 + if (XFS_INOBT_MASK(i) & ~r.ir_free) 473 + r.ir_freecount++; 468 474 } 469 - gfree |= xfs_inobt_maskn(0, chunkidx); 470 - irbp->ir_startino = gino; 471 - irbp->ir_freecount = gcnt; 472 - irbp->ir_free = gfree; 475 + r.ir_free |= xfs_inobt_maskn(0, chunkidx); 476 + irbp->ir_startino = r.ir_startino; 477 + irbp->ir_freecount = r.ir_freecount; 478 + irbp->ir_free = r.ir_free; 473 479 irbp++; 474 - agino = gino + XFS_INODES_PER_CHUNK; 475 - icount = XFS_INODES_PER_CHUNK - gcnt; 480 + agino = r.ir_startino + XFS_INODES_PER_CHUNK; 481 + icount = XFS_INODES_PER_CHUNK - r.ir_freecount; 476 482 } else { 477 483 /* 478 484 * If any of those tests failed, bump the ··· 493 493 /* 494 494 * Start of ag. Lookup the first inode chunk. 495 495 */ 496 - error = xfs_inobt_lookup_ge(cur, 0, 0, 0, &tmp); 496 + error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp); 497 497 icount = 0; 498 498 } 499 499 /* ··· 501 501 * until we run out of inodes or space in the buffer. 502 502 */ 503 503 while (irbp < irbufend && icount < ubcount) { 504 + xfs_inobt_rec_incore_t r; 505 + 504 506 /* 505 507 * Loop as long as we're unable to read the 506 508 * inode btree. ··· 512 510 if (XFS_AGINO_TO_AGBNO(mp, agino) >= 513 511 be32_to_cpu(agi->agi_length)) 514 512 break; 515 - error = xfs_inobt_lookup_ge(cur, agino, 0, 0, 516 - &tmp); 513 + error = xfs_inobt_lookup(cur, agino, 514 + XFS_LOOKUP_GE, &tmp); 517 515 cond_resched(); 518 516 } 519 517 /* 520 518 * If ran off the end of the ag either with an error, 521 519 * or the normal way, set end and stop collecting. 522 520 */ 523 - if (error || 524 - (error = xfs_inobt_get_rec(cur, &gino, &gcnt, 525 - &gfree, &i)) || 526 - i == 0) { 521 + if (error) { 527 522 end_of_ag = 1; 528 523 break; 529 524 } 525 + 526 + error = xfs_inobt_get_rec(cur, &r, &i); 527 + if (error || i == 0) { 528 + end_of_ag = 1; 529 + break; 530 + } 531 + 530 532 /* 531 533 * If this chunk has any allocated inodes, save it. 532 534 * Also start read-ahead now for this chunk. 533 535 */ 534 - if (gcnt < XFS_INODES_PER_CHUNK) { 536 + if (r.ir_freecount < XFS_INODES_PER_CHUNK) { 535 537 /* 536 538 * Loop over all clusters in the next chunk. 537 539 * Do a readahead if there are any allocated 538 540 * inodes in that cluster. 539 541 */ 540 - for (agbno = XFS_AGINO_TO_AGBNO(mp, gino), 541 - chunkidx = 0; 542 + agbno = XFS_AGINO_TO_AGBNO(mp, r.ir_startino); 543 + for (chunkidx = 0; 542 544 chunkidx < XFS_INODES_PER_CHUNK; 543 545 chunkidx += nicluster, 544 546 agbno += nbcluster) { 545 - if (xfs_inobt_maskn(chunkidx, 546 - nicluster) & ~gfree) 547 + if (xfs_inobt_maskn(chunkidx, nicluster) 548 + & ~r.ir_free) 547 549 xfs_btree_reada_bufs(mp, agno, 548 550 agbno, nbcluster); 549 551 } 550 - irbp->ir_startino = gino; 551 - irbp->ir_freecount = gcnt; 552 - irbp->ir_free = gfree; 552 + irbp->ir_startino = r.ir_startino; 553 + irbp->ir_freecount = r.ir_freecount; 554 + irbp->ir_free = r.ir_free; 553 555 irbp++; 554 - icount += XFS_INODES_PER_CHUNK - gcnt; 556 + icount += XFS_INODES_PER_CHUNK - r.ir_freecount; 555 557 } 556 558 /* 557 559 * Set agino to after this chunk and bump the cursor. 558 560 */ 559 - agino = gino + XFS_INODES_PER_CHUNK; 561 + agino = r.ir_startino + XFS_INODES_PER_CHUNK; 560 562 error = xfs_btree_increment(cur, 0, &tmp); 561 563 cond_resched(); 562 564 } ··· 826 820 int bufidx; 827 821 xfs_btree_cur_t *cur; 828 822 int error; 829 - __int32_t gcnt; 830 - xfs_inofree_t gfree; 831 - xfs_agino_t gino; 823 + xfs_inobt_rec_incore_t r; 832 824 int i; 833 825 xfs_ino_t ino; 834 826 int left; ··· 859 855 continue; 860 856 } 861 857 cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno); 862 - error = xfs_inobt_lookup_ge(cur, agino, 0, 0, &tmp); 858 + error = xfs_inobt_lookup(cur, agino, XFS_LOOKUP_GE, 859 + &tmp); 863 860 if (error) { 864 861 xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); 865 862 cur = NULL; ··· 875 870 continue; 876 871 } 877 872 } 878 - if ((error = xfs_inobt_get_rec(cur, &gino, &gcnt, &gfree, 879 - &i)) || 880 - i == 0) { 873 + error = xfs_inobt_get_rec(cur, &r, &i); 874 + if (error || i == 0) { 881 875 xfs_buf_relse(agbp); 882 876 agbp = NULL; 883 877 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); ··· 885 881 agino = 0; 886 882 continue; 887 883 } 888 - agino = gino + XFS_INODES_PER_CHUNK - 1; 889 - buffer[bufidx].xi_startino = XFS_AGINO_TO_INO(mp, agno, gino); 890 - buffer[bufidx].xi_alloccount = XFS_INODES_PER_CHUNK - gcnt; 891 - buffer[bufidx].xi_allocmask = ~gfree; 884 + agino = r.ir_startino + XFS_INODES_PER_CHUNK - 1; 885 + buffer[bufidx].xi_startino = 886 + XFS_AGINO_TO_INO(mp, agno, r.ir_startino); 887 + buffer[bufidx].xi_alloccount = 888 + XFS_INODES_PER_CHUNK - r.ir_freecount; 889 + buffer[bufidx].xi_allocmask = ~r.ir_free; 892 890 bufidx++; 893 891 left--; 894 892 if (bufidx == bcount) {
-5
fs/xfs/xfs_itable.h
··· 99 99 void *dibuff, 100 100 int *stat); 101 101 102 - int 103 - xfs_internal_inum( 104 - xfs_mount_t *mp, 105 - xfs_ino_t ino); 106 - 107 102 typedef int (*inumbers_fmt_pf)( 108 103 void __user *ubuffer, /* buffer to write to */ 109 104 const xfs_inogrp_t *buffer, /* buffer to read from */
-2
fs/xfs/xfs_log_priv.h
··· 451 451 extern int xlog_recover(xlog_t *log); 452 452 extern int xlog_recover_finish(xlog_t *log); 453 453 extern void xlog_pack_data(xlog_t *log, xlog_in_core_t *iclog, int); 454 - extern void xlog_recover_process_iunlinks(xlog_t *log); 455 - 456 454 extern struct xfs_buf *xlog_get_bp(xlog_t *, int); 457 455 extern void xlog_put_bp(struct xfs_buf *); 458 456
+1 -1
fs/xfs/xfs_log_recover.c
··· 3263 3263 * freeing of the inode and its removal from the list must be 3264 3264 * atomic. 3265 3265 */ 3266 - void 3266 + STATIC void 3267 3267 xlog_recover_process_iunlinks( 3268 3268 xlog_t *log) 3269 3269 {
+1 -1
fs/xfs/xfs_mount.c
··· 1568 1568 * 1569 1569 * The m_sb_lock must be held when this routine is called. 1570 1570 */ 1571 - int 1571 + STATIC int 1572 1572 xfs_mod_incore_sb_unlocked( 1573 1573 xfs_mount_t *mp, 1574 1574 xfs_sb_field_t field,
-3
fs/xfs/xfs_mount.h
··· 414 414 415 415 extern int xfs_log_sbcount(xfs_mount_t *, uint); 416 416 extern int xfs_mountfs(xfs_mount_t *mp); 417 - extern void xfs_mountfs_check_barriers(xfs_mount_t *mp); 418 417 419 418 extern void xfs_unmountfs(xfs_mount_t *); 420 419 extern int xfs_unmountfs_writesb(xfs_mount_t *); 421 420 extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int64_t, int); 422 - extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t, 423 - int64_t, int); 424 421 extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, 425 422 uint, int); 426 423 extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t);
-29
fs/xfs/xfs_mru_cache.c
··· 564 564 } 565 565 566 566 /* 567 - * To look up an element using its key, but leave its location in the internal 568 - * lists alone, call xfs_mru_cache_peek(). If the element isn't found, this 569 - * function returns NULL. 570 - * 571 - * See the comments above the declaration of the xfs_mru_cache_lookup() function 572 - * for important locking information pertaining to this call. 573 - */ 574 - void * 575 - xfs_mru_cache_peek( 576 - xfs_mru_cache_t *mru, 577 - unsigned long key) 578 - { 579 - xfs_mru_cache_elem_t *elem; 580 - 581 - ASSERT(mru && mru->lists); 582 - if (!mru || !mru->lists) 583 - return NULL; 584 - 585 - spin_lock(&mru->lock); 586 - elem = radix_tree_lookup(&mru->store, key); 587 - if (!elem) 588 - spin_unlock(&mru->lock); 589 - else 590 - __release(mru_lock); /* help sparse not be stupid */ 591 - 592 - return elem ? elem->value : NULL; 593 - } 594 - 595 - /* 596 567 * To release the internal data structure spinlock after having performed an 597 568 * xfs_mru_cache_lookup() or an xfs_mru_cache_peek(), call xfs_mru_cache_done() 598 569 * with the data store pointer.
-1
fs/xfs/xfs_mru_cache.h
··· 49 49 void * xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key); 50 50 void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key); 51 51 void *xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key); 52 - void *xfs_mru_cache_peek(struct xfs_mru_cache *mru, unsigned long key); 53 52 void xfs_mru_cache_done(struct xfs_mru_cache *mru); 54 53 55 54 #endif /* __XFS_MRU_CACHE_H__ */
-84
fs/xfs/xfs_rw.c
··· 88 88 } 89 89 90 90 /* 91 - * Handle logging requirements of various synchronous types of write. 92 - */ 93 - int 94 - xfs_write_sync_logforce( 95 - xfs_mount_t *mp, 96 - xfs_inode_t *ip) 97 - { 98 - int error = 0; 99 - 100 - /* 101 - * If we're treating this as O_DSYNC and we have not updated the 102 - * size, force the log. 103 - */ 104 - if (!(mp->m_flags & XFS_MOUNT_OSYNCISOSYNC) && 105 - !(ip->i_update_size)) { 106 - xfs_inode_log_item_t *iip = ip->i_itemp; 107 - 108 - /* 109 - * If an allocation transaction occurred 110 - * without extending the size, then we have to force 111 - * the log up the proper point to ensure that the 112 - * allocation is permanent. We can't count on 113 - * the fact that buffered writes lock out direct I/O 114 - * writes - the direct I/O write could have extended 115 - * the size nontransactionally, then finished before 116 - * we started. xfs_write_file will think that the file 117 - * didn't grow but the update isn't safe unless the 118 - * size change is logged. 119 - * 120 - * Force the log if we've committed a transaction 121 - * against the inode or if someone else has and 122 - * the commit record hasn't gone to disk (e.g. 123 - * the inode is pinned). This guarantees that 124 - * all changes affecting the inode are permanent 125 - * when we return. 126 - */ 127 - if (iip && iip->ili_last_lsn) { 128 - error = _xfs_log_force(mp, iip->ili_last_lsn, 129 - XFS_LOG_FORCE | XFS_LOG_SYNC, NULL); 130 - } else if (xfs_ipincount(ip) > 0) { 131 - error = _xfs_log_force(mp, (xfs_lsn_t)0, 132 - XFS_LOG_FORCE | XFS_LOG_SYNC, NULL); 133 - } 134 - 135 - } else { 136 - xfs_trans_t *tp; 137 - 138 - /* 139 - * O_SYNC or O_DSYNC _with_ a size update are handled 140 - * the same way. 141 - * 142 - * If the write was synchronous then we need to make 143 - * sure that the inode modification time is permanent. 144 - * We'll have updated the timestamp above, so here 145 - * we use a synchronous transaction to log the inode. 146 - * It's not fast, but it's necessary. 147 - * 148 - * If this a dsync write and the size got changed 149 - * non-transactionally, then we need to ensure that 150 - * the size change gets logged in a synchronous 151 - * transaction. 152 - */ 153 - tp = xfs_trans_alloc(mp, XFS_TRANS_WRITE_SYNC); 154 - if ((error = xfs_trans_reserve(tp, 0, 155 - XFS_SWRITE_LOG_RES(mp), 156 - 0, 0, 0))) { 157 - /* Transaction reserve failed */ 158 - xfs_trans_cancel(tp, 0); 159 - } else { 160 - /* Transaction reserve successful */ 161 - xfs_ilock(ip, XFS_ILOCK_EXCL); 162 - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 163 - xfs_trans_ihold(tp, ip); 164 - xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 165 - xfs_trans_set_sync(tp); 166 - error = xfs_trans_commit(tp, 0); 167 - xfs_iunlock(ip, XFS_ILOCK_EXCL); 168 - } 169 - } 170 - 171 - return error; 172 - } 173 - 174 - /* 175 91 * Force a shutdown of the filesystem instantly while keeping 176 92 * the filesystem consistent. We don't do an unmount here; just shutdown 177 93 * the shop, make sure that absolutely nothing persistent happens to
-7
fs/xfs/xfs_rw.h
··· 68 68 * Prototypes for functions in xfs_rw.c. 69 69 */ 70 70 extern int xfs_write_clear_setuid(struct xfs_inode *ip); 71 - extern int xfs_write_sync_logforce(struct xfs_mount *mp, struct xfs_inode *ip); 72 71 extern int xfs_bwrite(struct xfs_mount *mp, struct xfs_buf *bp); 73 72 extern int xfs_bioerror(struct xfs_buf *bp); 74 73 extern int xfs_bioerror_relse(struct xfs_buf *bp); ··· 76 77 struct xfs_buf **bpp); 77 78 extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp, 78 79 xfs_buf_t *bp, xfs_daddr_t blkno); 79 - 80 - /* 81 - * Prototypes for functions in xfs_vnodeops.c. 82 - */ 83 - extern int xfs_free_eofblocks(struct xfs_mount *mp, struct xfs_inode *ip, 84 - int flags); 85 80 86 81 #endif /* __XFS_RW_H__ */
+1 -1
fs/xfs/xfs_trans.h
··· 68 68 #define XFS_TRANS_GROWFS 14 69 69 #define XFS_TRANS_STRAT_WRITE 15 70 70 #define XFS_TRANS_DIOSTRAT 16 71 - #define XFS_TRANS_WRITE_SYNC 17 71 + /* 17 was XFS_TRANS_WRITE_SYNC */ 72 72 #define XFS_TRANS_WRITEID 18 73 73 #define XFS_TRANS_ADDAFORK 19 74 74 #define XFS_TRANS_ATTRINVAL 20
+2 -2
fs/xfs/xfs_trans_buf.c
··· 307 307 return (flags & XFS_BUF_TRYLOCK) ? 308 308 EAGAIN : XFS_ERROR(ENOMEM); 309 309 310 - if ((bp != NULL) && (XFS_BUF_GETERROR(bp) != 0)) { 310 + if (XFS_BUF_GETERROR(bp) != 0) { 311 311 xfs_ioerror_alert("xfs_trans_read_buf", mp, 312 312 bp, blkno); 313 313 error = XFS_BUF_GETERROR(bp); ··· 315 315 return error; 316 316 } 317 317 #ifdef DEBUG 318 - if (xfs_do_error && (bp != NULL)) { 318 + if (xfs_do_error) { 319 319 if (xfs_error_target == target) { 320 320 if (((xfs_req_num++) % xfs_error_mod) == 0) { 321 321 xfs_buf_relse(bp);
+5 -81
fs/xfs/xfs_trans_inode.c
··· 49 49 50 50 51 51 /* 52 - * Get and lock the inode for the caller if it is not already 53 - * locked within the given transaction. If it is already locked 54 - * within the transaction, just increment its lock recursion count 55 - * and return a pointer to it. 56 - * 57 - * For an inode to be locked in a transaction, the inode lock, as 58 - * opposed to the io lock, must be taken exclusively. This ensures 59 - * that the inode can be involved in only 1 transaction at a time. 60 - * Lock recursion is handled on the io lock, but only for lock modes 61 - * of equal or lesser strength. That is, you can recur on the io lock 62 - * held EXCL with a SHARED request but not vice versa. Also, if 63 - * the inode is already a part of the transaction then you cannot 64 - * go from not holding the io lock to having it EXCL or SHARED. 65 - * 66 - * Use the inode cache routine xfs_inode_incore() to find the inode 67 - * if it is already owned by this transaction. 68 - * 69 - * If we don't already own the inode, use xfs_iget() to get it. 70 - * Since the inode log item structure is embedded in the incore 71 - * inode structure and is initialized when the inode is brought 72 - * into memory, there is nothing to do with it here. 73 - * 74 - * If the given transaction pointer is NULL, just call xfs_iget(). 75 - * This simplifies code which must handle both cases. 52 + * Get an inode and join it to the transaction. 76 53 */ 77 54 int 78 55 xfs_trans_iget( ··· 61 84 xfs_inode_t **ipp) 62 85 { 63 86 int error; 64 - xfs_inode_t *ip; 65 87 66 - /* 67 - * If the transaction pointer is NULL, just call the normal 68 - * xfs_iget(). 69 - */ 70 - if (tp == NULL) 71 - return xfs_iget(mp, NULL, ino, flags, lock_flags, ipp, 0); 72 - 73 - /* 74 - * If we find the inode in core with this transaction 75 - * pointer in its i_transp field, then we know we already 76 - * have it locked. In this case we just increment the lock 77 - * recursion count and return the inode to the caller. 78 - * Assert that the inode is already locked in the mode requested 79 - * by the caller. We cannot do lock promotions yet, so 80 - * die if someone gets this wrong. 81 - */ 82 - if ((ip = xfs_inode_incore(tp->t_mountp, ino, tp)) != NULL) { 83 - /* 84 - * Make sure that the inode lock is held EXCL and 85 - * that the io lock is never upgraded when the inode 86 - * is already a part of the transaction. 87 - */ 88 - ASSERT(ip->i_itemp != NULL); 89 - ASSERT(lock_flags & XFS_ILOCK_EXCL); 90 - ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 91 - ASSERT((!(lock_flags & XFS_IOLOCK_EXCL)) || 92 - xfs_isilocked(ip, XFS_IOLOCK_EXCL)); 93 - ASSERT((!(lock_flags & XFS_IOLOCK_EXCL)) || 94 - (ip->i_itemp->ili_flags & XFS_ILI_IOLOCKED_EXCL)); 95 - ASSERT((!(lock_flags & XFS_IOLOCK_SHARED)) || 96 - xfs_isilocked(ip, XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)); 97 - ASSERT((!(lock_flags & XFS_IOLOCK_SHARED)) || 98 - (ip->i_itemp->ili_flags & XFS_ILI_IOLOCKED_ANY)); 99 - 100 - if (lock_flags & (XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL)) { 101 - ip->i_itemp->ili_iolock_recur++; 102 - } 103 - if (lock_flags & XFS_ILOCK_EXCL) { 104 - ip->i_itemp->ili_ilock_recur++; 105 - } 106 - *ipp = ip; 107 - return 0; 108 - } 109 - 110 - ASSERT(lock_flags & XFS_ILOCK_EXCL); 111 - error = xfs_iget(tp->t_mountp, tp, ino, flags, lock_flags, &ip, 0); 112 - if (error) { 113 - return error; 114 - } 115 - ASSERT(ip != NULL); 116 - 117 - xfs_trans_ijoin(tp, ip, lock_flags); 118 - *ipp = ip; 119 - return 0; 88 + error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp, 0); 89 + if (!error && tp) 90 + xfs_trans_ijoin(tp, *ipp, lock_flags); 91 + return error; 120 92 } 121 93 122 94 /* ··· 89 163 xfs_inode_item_init(ip, ip->i_mount); 90 164 iip = ip->i_itemp; 91 165 ASSERT(iip->ili_flags == 0); 92 - ASSERT(iip->ili_ilock_recur == 0); 93 - ASSERT(iip->ili_iolock_recur == 0); 94 166 95 167 /* 96 168 * Get a log_item_desc to point at the new item.
+6 -11
fs/xfs/xfs_vnodeops.c
··· 611 611 xfs_inode_t *ip) 612 612 { 613 613 xfs_trans_t *tp; 614 - int error; 614 + int error = 0; 615 615 int log_flushed = 0, changed = 1; 616 616 617 617 xfs_itrace_entry(ip); ··· 619 619 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 620 620 return XFS_ERROR(EIO); 621 621 622 - /* capture size updates in I/O completion before writing the inode. */ 623 - error = xfs_wait_on_pages(ip, 0, -1); 624 - if (error) 625 - return XFS_ERROR(error); 626 - 627 622 /* 628 623 * We always need to make sure that the required inode state is safe on 629 - * disk. The vnode might be clean but we still might need to force the 624 + * disk. The inode might be clean but we still might need to force the 630 625 * log because of committed transactions that haven't hit the disk yet. 631 626 * Likewise, there could be unflushed non-transactional changes to the 632 627 * inode core that have to go to disk and this requires us to issue ··· 633 638 */ 634 639 xfs_ilock(ip, XFS_ILOCK_SHARED); 635 640 636 - if (!(ip->i_update_size || ip->i_update_core)) { 641 + if (!ip->i_update_core) { 637 642 /* 638 643 * Timestamps/size haven't changed since last inode flush or 639 644 * inode transaction commit. That means either nothing got ··· 713 718 * when the link count isn't zero and by xfs_dm_punch_hole() when 714 719 * punching a hole to EOF. 715 720 */ 716 - int 721 + STATIC int 717 722 xfs_free_eofblocks( 718 723 xfs_mount_t *mp, 719 724 xfs_inode_t *ip, ··· 1471 1476 if (error == ENOSPC) { 1472 1477 /* flush outstanding delalloc blocks and retry */ 1473 1478 xfs_flush_inodes(dp); 1474 - error = xfs_trans_reserve(tp, resblks, XFS_CREATE_LOG_RES(mp), 0, 1475 - XFS_TRANS_PERM_LOG_RES, XFS_CREATE_LOG_COUNT); 1479 + error = xfs_trans_reserve(tp, resblks, log_res, 0, 1480 + XFS_TRANS_PERM_LOG_RES, log_count); 1476 1481 } 1477 1482 if (error == ENOSPC) { 1478 1483 /* No space at all so try a "no-allocation" reservation */