aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-04-18 02:56:30 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-18 02:56:30 -0400
commit1e42198609d73ed1a9adcba2af275c24c2678420 (patch)
tree32fd4d9073bfc0f3909af8f9fb4bcff38951d01a /fs
parent794eb6bf20ebf992c040ea831cd3a9c64b0c1f7a (diff)
parent4b119e21d0c66c22e8ca03df05d9de623d0eb50f (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs')
-rw-r--r--fs/Kconfig8
-rw-r--r--fs/afs/internal.h2
-rw-r--r--fs/afs/main.c2
-rw-r--r--fs/aio.c18
-rw-r--r--fs/buffer.c15
-rw-r--r--fs/ext2/xattr.c2
-rw-r--r--fs/ext3/xattr.c2
-rw-r--r--fs/ext4/xattr.c2
-rw-r--r--fs/hfsplus/dir.c23
-rw-r--r--fs/jffs2/file.c2
-rw-r--r--fs/locks.c48
-rw-r--r--fs/mbcache.c4
-rw-r--r--fs/nfs/file.c4
-rw-r--r--fs/nfs/inode.c1
-rw-r--r--fs/open.c8
-rw-r--r--fs/signalfd.c7
-rw-r--r--fs/splice.c33
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c2
-rw-r--r--fs/xfs/quota/xfs_qm.c6
-rw-r--r--fs/xfs/quota/xfs_qm_bhv.c2
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c4
-rw-r--r--fs/xfs/xfs_attr_leaf.c6
-rw-r--r--fs/xfs/xfs_bmap.c18
-rw-r--r--fs/xfs/xfs_bmap_btree.h2
-rw-r--r--fs/xfs/xfs_dir2.c2
-rw-r--r--fs/xfs/xfs_fsops.c24
-rw-r--r--fs/xfs/xfs_ialloc.c6
-rw-r--r--fs/xfs/xfs_inode.c6
-rw-r--r--fs/xfs/xfs_inode_item.c4
-rw-r--r--fs/xfs/xfs_itable.c2
-rw-r--r--fs/xfs/xfs_log.c14
-rw-r--r--fs/xfs/xfs_log_priv.h4
-rw-r--r--fs/xfs/xfs_log_recover.c16
-rw-r--r--fs/xfs/xfs_mount.c59
-rw-r--r--fs/xfs/xfs_sb.h107
-rw-r--r--fs/xfs/xfs_utils.c6
-rw-r--r--fs/xfs/xfs_vfsops.c9
-rw-r--r--fs/xfs/xfs_vnodeops.c2
38 files changed, 254 insertions, 228 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index d7312825592b..c509123bea49 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1744,10 +1744,10 @@ config ROOT_NFS
1744 If you want your Linux box to mount its whole root file system (the 1744 If you want your Linux box to mount its whole root file system (the
1745 one containing the directory /) from some other computer over the 1745 one containing the directory /) from some other computer over the
1746 net via NFS (presumably because your box doesn't have a hard disk), 1746 net via NFS (presumably because your box doesn't have a hard disk),
1747 say Y. Read <file:Documentation/nfsroot.txt> for details. It is 1747 say Y. Read <file:Documentation/filesystems/nfsroot.txt> for
1748 likely that in this case, you also want to say Y to "Kernel level IP 1748 details. It is likely that in this case, you also want to say Y to
1749 autoconfiguration" so that your box can discover its network address 1749 "Kernel level IP autoconfiguration" so that your box can discover
1750 at boot time. 1750 its network address at boot time.
1751 1751
1752 Most people say N here. 1752 Most people say N here.
1753 1753
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 9ba16edc0af2..eec41c76de72 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -749,7 +749,7 @@ extern int afs_fsync(struct file *, struct dentry *, int);
749extern unsigned afs_debug; 749extern unsigned afs_debug;
750 750
751#define dbgprintk(FMT,...) \ 751#define dbgprintk(FMT,...) \
752 printk("[%x%-6.6s] "FMT"\n", smp_processor_id(), current->comm ,##__VA_ARGS__) 752 printk("[%-6.6s] "FMT"\n", current->comm ,##__VA_ARGS__)
753 753
754/* make sure we maintain the format strings, even when debugging is disabled */ 754/* make sure we maintain the format strings, even when debugging is disabled */
755static inline __attribute__((format(printf,1,2))) 755static inline __attribute__((format(printf,1,2)))
diff --git a/fs/afs/main.c b/fs/afs/main.c
index 0f60f6b35769..2d3e5d4fb9f7 100644
--- a/fs/afs/main.c
+++ b/fs/afs/main.c
@@ -22,7 +22,7 @@ MODULE_LICENSE("GPL");
22 22
23unsigned afs_debug; 23unsigned afs_debug;
24module_param_named(debug, afs_debug, uint, S_IWUSR | S_IRUGO); 24module_param_named(debug, afs_debug, uint, S_IWUSR | S_IRUGO);
25MODULE_PARM_DESC(afs_debug, "AFS debugging mask"); 25MODULE_PARM_DESC(debug, "AFS debugging mask");
26 26
27static char *rootcell; 27static char *rootcell;
28 28
diff --git a/fs/aio.c b/fs/aio.c
index 6af921940622..228368610dfa 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -936,14 +936,6 @@ int aio_complete(struct kiocb *iocb, long res, long res2)
936 return 1; 936 return 1;
937 } 937 }
938 938
939 /*
940 * Check if the user asked us to deliver the result through an
941 * eventfd. The eventfd_signal() function is safe to be called
942 * from IRQ context.
943 */
944 if (!IS_ERR(iocb->ki_eventfd))
945 eventfd_signal(iocb->ki_eventfd, 1);
946
947 info = &ctx->ring_info; 939 info = &ctx->ring_info;
948 940
949 /* add a completion event to the ring buffer. 941 /* add a completion event to the ring buffer.
@@ -992,6 +984,15 @@ int aio_complete(struct kiocb *iocb, long res, long res2)
992 kunmap_atomic(ring, KM_IRQ1); 984 kunmap_atomic(ring, KM_IRQ1);
993 985
994 pr_debug("added to ring %p at [%lu]\n", iocb, tail); 986 pr_debug("added to ring %p at [%lu]\n", iocb, tail);
987
988 /*
989 * Check if the user asked us to deliver the result through an
990 * eventfd. The eventfd_signal() function is safe to be called
991 * from IRQ context.
992 */
993 if (!IS_ERR(iocb->ki_eventfd))
994 eventfd_signal(iocb->ki_eventfd, 1);
995
995put_rq: 996put_rq:
996 /* everything turned out well, dispose of the aiocb. */ 997 /* everything turned out well, dispose of the aiocb. */
997 ret = __aio_put_req(ctx, iocb); 998 ret = __aio_put_req(ctx, iocb);
@@ -1790,6 +1791,7 @@ asmlinkage long sys_io_getevents(aio_context_t ctx_id,
1790 put_ioctx(ioctx); 1791 put_ioctx(ioctx);
1791 } 1792 }
1792 1793
1794 asmlinkage_protect(5, ret, ctx_id, min_nr, nr, events, timeout);
1793 return ret; 1795 return ret;
1794} 1796}
1795 1797
diff --git a/fs/buffer.c b/fs/buffer.c
index 98196327ddf0..39ff14403d13 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1181,7 +1181,20 @@ __getblk_slow(struct block_device *bdev, sector_t block, int size)
1181void mark_buffer_dirty(struct buffer_head *bh) 1181void mark_buffer_dirty(struct buffer_head *bh)
1182{ 1182{
1183 WARN_ON_ONCE(!buffer_uptodate(bh)); 1183 WARN_ON_ONCE(!buffer_uptodate(bh));
1184 if (!buffer_dirty(bh) && !test_set_buffer_dirty(bh)) 1184
1185 /*
1186 * Very *carefully* optimize the it-is-already-dirty case.
1187 *
1188 * Don't let the final "is it dirty" escape to before we
1189 * perhaps modified the buffer.
1190 */
1191 if (buffer_dirty(bh)) {
1192 smp_mb();
1193 if (buffer_dirty(bh))
1194 return;
1195 }
1196
1197 if (!test_set_buffer_dirty(bh))
1185 __set_page_dirty(bh->b_page, page_mapping(bh->b_page), 0); 1198 __set_page_dirty(bh->b_page, page_mapping(bh->b_page), 0);
1186} 1199}
1187 1200
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 3e8683dbb13f..a99d46f3b26e 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -835,7 +835,7 @@ ext2_xattr_cache_insert(struct buffer_head *bh)
835 struct mb_cache_entry *ce; 835 struct mb_cache_entry *ce;
836 int error; 836 int error;
837 837
838 ce = mb_cache_entry_alloc(ext2_xattr_cache); 838 ce = mb_cache_entry_alloc(ext2_xattr_cache, GFP_NOFS);
839 if (!ce) 839 if (!ce)
840 return -ENOMEM; 840 return -ENOMEM;
841 error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, &hash); 841 error = mb_cache_entry_insert(ce, bh->b_bdev, bh->b_blocknr, &hash);
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index a6ea4d6a8bb2..42856541e9a5 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -1126,7 +1126,7 @@ ext3_xattr_cache_insert(struct buffer_head *bh)
1126 struct mb_cache_entry *ce; 1126 struct mb_cache_entry *ce;
1127 int error; 1127 int error;
1128 1128
1129 ce = mb_cache_entry_alloc(ext3_xattr_cache); 1129 ce = mb_cache_entry_alloc(ext3_xattr_cache, GFP_NOFS);
1130 if (!ce) { 1130 if (!ce) {
1131 ea_bdebug(bh, "out of memory"); 1131 ea_bdebug(bh, "out of memory");
1132 return; 1132 return;
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index d7962139c010..e9054c1c7d93 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1386,7 +1386,7 @@ ext4_xattr_cache_insert(struct buffer_head *bh)
1386 struct mb_cache_entry *ce; 1386 struct mb_cache_entry *ce;
1387 int error; 1387 int error;
1388 1388
1389 ce = mb_cache_entry_alloc(ext4_xattr_cache); 1389 ce = mb_cache_entry_alloc(ext4_xattr_cache, GFP_NOFS);
1390 if (!ce) { 1390 if (!ce) {
1391 ea_bdebug(bh, "out of memory"); 1391 ea_bdebug(bh, "out of memory");
1392 return; 1392 return;
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 29683645fa0a..5f4023678251 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -340,16 +340,23 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
340 340
341 if (inode->i_nlink > 0) 341 if (inode->i_nlink > 0)
342 drop_nlink(inode); 342 drop_nlink(inode);
343 hfsplus_delete_inode(inode); 343 if (inode->i_ino == cnid)
344 if (inode->i_ino != cnid && !inode->i_nlink) { 344 clear_nlink(inode);
345 if (!atomic_read(&HFSPLUS_I(inode).opencnt)) { 345 if (!inode->i_nlink) {
346 res = hfsplus_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL); 346 if (inode->i_ino != cnid) {
347 if (!res) 347 HFSPLUS_SB(sb).file_count--;
348 hfsplus_delete_inode(inode); 348 if (!atomic_read(&HFSPLUS_I(inode).opencnt)) {
349 res = hfsplus_delete_cat(inode->i_ino,
350 HFSPLUS_SB(sb).hidden_dir,
351 NULL);
352 if (!res)
353 hfsplus_delete_inode(inode);
354 } else
355 inode->i_flags |= S_DEAD;
349 } else 356 } else
350 inode->i_flags |= S_DEAD; 357 hfsplus_delete_inode(inode);
351 } else 358 } else
352 clear_nlink(inode); 359 HFSPLUS_SB(sb).file_count--;
353 inode->i_ctime = CURRENT_TIME_SEC; 360 inode->i_ctime = CURRENT_TIME_SEC;
354 mark_inode_dirty(inode); 361 mark_inode_dirty(inode);
355 362
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index f9c5dd6f4b64..dcc2734e0b5d 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -129,7 +129,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
129 struct inode *inode = mapping->host; 129 struct inode *inode = mapping->host;
130 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 130 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
131 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 131 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
132 uint32_t pageofs = pos & (PAGE_CACHE_SIZE - 1); 132 uint32_t pageofs = index << PAGE_CACHE_SHIFT;
133 int ret = 0; 133 int ret = 0;
134 134
135 pg = __grab_cache_page(mapping, index); 135 pg = __grab_cache_page(mapping, index);
diff --git a/fs/locks.c b/fs/locks.c
index d83fab1b77b5..43c0af21a0c5 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1801,17 +1801,21 @@ again:
1801 if (error) 1801 if (error)
1802 goto out; 1802 goto out;
1803 1803
1804 for (;;) { 1804 if (filp->f_op && filp->f_op->lock != NULL)
1805 error = vfs_lock_file(filp, cmd, file_lock, NULL); 1805 error = filp->f_op->lock(filp, cmd, file_lock);
1806 if (error != -EAGAIN || cmd == F_SETLK) 1806 else {
1807 break; 1807 for (;;) {
1808 error = wait_event_interruptible(file_lock->fl_wait, 1808 error = posix_lock_file(filp, file_lock, NULL);
1809 !file_lock->fl_next); 1809 if (error != -EAGAIN || cmd == F_SETLK)
1810 if (!error) 1810 break;
1811 continue; 1811 error = wait_event_interruptible(file_lock->fl_wait,
1812 !file_lock->fl_next);
1813 if (!error)
1814 continue;
1812 1815
1813 locks_delete_block(file_lock); 1816 locks_delete_block(file_lock);
1814 break; 1817 break;
1818 }
1815 } 1819 }
1816 1820
1817 /* 1821 /*
@@ -1925,17 +1929,21 @@ again:
1925 if (error) 1929 if (error)
1926 goto out; 1930 goto out;
1927 1931
1928 for (;;) { 1932 if (filp->f_op && filp->f_op->lock != NULL)
1929 error = vfs_lock_file(filp, cmd, file_lock, NULL); 1933 error = filp->f_op->lock(filp, cmd, file_lock);
1930 if (error != -EAGAIN || cmd == F_SETLK64) 1934 else {
1931 break; 1935 for (;;) {
1932 error = wait_event_interruptible(file_lock->fl_wait, 1936 error = posix_lock_file(filp, file_lock, NULL);
1933 !file_lock->fl_next); 1937 if (error != -EAGAIN || cmd == F_SETLK64)
1934 if (!error) 1938 break;
1935 continue; 1939 error = wait_event_interruptible(file_lock->fl_wait,
1940 !file_lock->fl_next);
1941 if (!error)
1942 continue;
1936 1943
1937 locks_delete_block(file_lock); 1944 locks_delete_block(file_lock);
1938 break; 1945 break;
1946 }
1939 } 1947 }
1940 1948
1941 /* 1949 /*
diff --git a/fs/mbcache.c b/fs/mbcache.c
index eb31b73e7d69..ec88ff3d04a9 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -399,11 +399,11 @@ mb_cache_destroy(struct mb_cache *cache)
399 * if no more memory was available. 399 * if no more memory was available.
400 */ 400 */
401struct mb_cache_entry * 401struct mb_cache_entry *
402mb_cache_entry_alloc(struct mb_cache *cache) 402mb_cache_entry_alloc(struct mb_cache *cache, gfp_t gfp_flags)
403{ 403{
404 struct mb_cache_entry *ce; 404 struct mb_cache_entry *ce;
405 405
406 ce = kmem_cache_alloc(cache->c_entry_cache, GFP_KERNEL); 406 ce = kmem_cache_alloc(cache->c_entry_cache, gfp_flags);
407 if (ce) { 407 if (ce) {
408 atomic_inc(&cache->c_entry_count); 408 atomic_inc(&cache->c_entry_count);
409 INIT_LIST_HEAD(&ce->e_lru_list); 409 INIT_LIST_HEAD(&ce->e_lru_list);
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index ef57a5ae5904..5d2e9d9a4e28 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -64,7 +64,11 @@ const struct file_operations nfs_file_operations = {
64 .write = do_sync_write, 64 .write = do_sync_write,
65 .aio_read = nfs_file_read, 65 .aio_read = nfs_file_read,
66 .aio_write = nfs_file_write, 66 .aio_write = nfs_file_write,
67#ifdef CONFIG_MMU
67 .mmap = nfs_file_mmap, 68 .mmap = nfs_file_mmap,
69#else
70 .mmap = generic_file_mmap,
71#endif
68 .open = nfs_file_open, 72 .open = nfs_file_open,
69 .flush = nfs_file_flush, 73 .flush = nfs_file_flush,
70 .release = nfs_file_release, 74 .release = nfs_file_release,
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index a4c7cf2bff3a..6f88d7c77ac9 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -506,6 +506,7 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str
506 ctx->cred = get_rpccred(cred); 506 ctx->cred = get_rpccred(cred);
507 ctx->state = NULL; 507 ctx->state = NULL;
508 ctx->lockowner = current->files; 508 ctx->lockowner = current->files;
509 ctx->flags = 0;
509 ctx->error = 0; 510 ctx->error = 0;
510 ctx->dir_cookie = 0; 511 ctx->dir_cookie = 0;
511 atomic_set(&ctx->count, 1); 512 atomic_set(&ctx->count, 1);
diff --git a/fs/open.c b/fs/open.c
index a4b12022edaa..3fa4e4ffce4c 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -335,7 +335,7 @@ asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
335{ 335{
336 long ret = do_sys_ftruncate(fd, length, 1); 336 long ret = do_sys_ftruncate(fd, length, 1);
337 /* avoid REGPARM breakage on x86: */ 337 /* avoid REGPARM breakage on x86: */
338 prevent_tail_call(ret); 338 asmlinkage_protect(2, ret, fd, length);
339 return ret; 339 return ret;
340} 340}
341 341
@@ -350,7 +350,7 @@ asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
350{ 350{
351 long ret = do_sys_ftruncate(fd, length, 0); 351 long ret = do_sys_ftruncate(fd, length, 0);
352 /* avoid REGPARM breakage on x86: */ 352 /* avoid REGPARM breakage on x86: */
353 prevent_tail_call(ret); 353 asmlinkage_protect(2, ret, fd, length);
354 return ret; 354 return ret;
355} 355}
356#endif 356#endif
@@ -1067,7 +1067,7 @@ asmlinkage long sys_open(const char __user *filename, int flags, int mode)
1067 1067
1068 ret = do_sys_open(AT_FDCWD, filename, flags, mode); 1068 ret = do_sys_open(AT_FDCWD, filename, flags, mode);
1069 /* avoid REGPARM breakage on x86: */ 1069 /* avoid REGPARM breakage on x86: */
1070 prevent_tail_call(ret); 1070 asmlinkage_protect(3, ret, filename, flags, mode);
1071 return ret; 1071 return ret;
1072} 1072}
1073 1073
@@ -1081,7 +1081,7 @@ asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
1081 1081
1082 ret = do_sys_open(dfd, filename, flags, mode); 1082 ret = do_sys_open(dfd, filename, flags, mode);
1083 /* avoid REGPARM breakage on x86: */ 1083 /* avoid REGPARM breakage on x86: */
1084 prevent_tail_call(ret); 1084 asmlinkage_protect(4, ret, dfd, filename, flags, mode);
1085 return ret; 1085 return ret;
1086} 1086}
1087 1087
diff --git a/fs/signalfd.c b/fs/signalfd.c
index cb2b63ae0bf4..8ead0db35933 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -111,9 +111,14 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
111 err |= __put_user(kinfo->si_uid, &uinfo->ssi_uid); 111 err |= __put_user(kinfo->si_uid, &uinfo->ssi_uid);
112 err |= __put_user((long) kinfo->si_ptr, &uinfo->ssi_ptr); 112 err |= __put_user((long) kinfo->si_ptr, &uinfo->ssi_ptr);
113 break; 113 break;
114 default: /* this is just in case for now ... */ 114 default:
115 /*
116 * This case catches also the signals queued by sigqueue().
117 */
115 err |= __put_user(kinfo->si_pid, &uinfo->ssi_pid); 118 err |= __put_user(kinfo->si_pid, &uinfo->ssi_pid);
116 err |= __put_user(kinfo->si_uid, &uinfo->ssi_uid); 119 err |= __put_user(kinfo->si_uid, &uinfo->ssi_uid);
120 err |= __put_user((long) kinfo->si_ptr, &uinfo->ssi_ptr);
121 err |= __put_user(kinfo->si_int, &uinfo->ssi_int);
117 break; 122 break;
118 } 123 }
119 124
diff --git a/fs/splice.c b/fs/splice.c
index 0670c915cd35..eeb1a86a7014 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -320,7 +320,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
320 break; 320 break;
321 321
322 error = add_to_page_cache_lru(page, mapping, index, 322 error = add_to_page_cache_lru(page, mapping, index,
323 GFP_KERNEL); 323 mapping_gfp_mask(mapping));
324 if (unlikely(error)) { 324 if (unlikely(error)) {
325 page_cache_release(page); 325 page_cache_release(page);
326 if (error == -EEXIST) 326 if (error == -EEXIST)
@@ -370,8 +370,10 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
370 * for an in-flight io page 370 * for an in-flight io page
371 */ 371 */
372 if (flags & SPLICE_F_NONBLOCK) { 372 if (flags & SPLICE_F_NONBLOCK) {
373 if (TestSetPageLocked(page)) 373 if (TestSetPageLocked(page)) {
374 error = -EAGAIN;
374 break; 375 break;
376 }
375 } else 377 } else
376 lock_page(page); 378 lock_page(page);
377 379
@@ -479,9 +481,8 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
479 struct pipe_inode_info *pipe, size_t len, 481 struct pipe_inode_info *pipe, size_t len,
480 unsigned int flags) 482 unsigned int flags)
481{ 483{
482 ssize_t spliced;
483 int ret;
484 loff_t isize, left; 484 loff_t isize, left;
485 int ret;
485 486
486 isize = i_size_read(in->f_mapping->host); 487 isize = i_size_read(in->f_mapping->host);
487 if (unlikely(*ppos >= isize)) 488 if (unlikely(*ppos >= isize))
@@ -491,29 +492,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
491 if (unlikely(left < len)) 492 if (unlikely(left < len))
492 len = left; 493 len = left;
493 494
494 ret = 0; 495 ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
495 spliced = 0; 496 if (ret > 0)
496 while (len && !spliced) {
497 ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
498
499 if (ret < 0)
500 break;
501 else if (!ret) {
502 if (spliced)
503 break;
504 if (flags & SPLICE_F_NONBLOCK) {
505 ret = -EAGAIN;
506 break;
507 }
508 }
509
510 *ppos += ret; 497 *ppos += ret;
511 len -= ret;
512 spliced += ret;
513 }
514
515 if (spliced)
516 return spliced;
517 498
518 return ret; 499 return ret;
519} 500}
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index a9952e490ac9..f34bd010eb51 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -732,7 +732,7 @@ xfs_ioctl(
732 * Only allow the sys admin to reserve space unless 732 * Only allow the sys admin to reserve space unless
733 * unwritten extents are enabled. 733 * unwritten extents are enabled.
734 */ 734 */
735 if (!XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) && 735 if (!xfs_sb_version_hasextflgbit(&mp->m_sb) &&
736 !capable(CAP_SYS_ADMIN)) 736 !capable(CAP_SYS_ADMIN))
737 return -EPERM; 737 return -EPERM;
738 738
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 1f3da5b8657b..8e9c5ae6504d 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -1405,13 +1405,13 @@ xfs_qm_qino_alloc(
1405#if defined(DEBUG) && defined(XFS_LOUD_RECOVERY) 1405#if defined(DEBUG) && defined(XFS_LOUD_RECOVERY)
1406 unsigned oldv = mp->m_sb.sb_versionnum; 1406 unsigned oldv = mp->m_sb.sb_versionnum;
1407#endif 1407#endif
1408 ASSERT(!XFS_SB_VERSION_HASQUOTA(&mp->m_sb)); 1408 ASSERT(!xfs_sb_version_hasquota(&mp->m_sb));
1409 ASSERT((sbfields & (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | 1409 ASSERT((sbfields & (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
1410 XFS_SB_GQUOTINO | XFS_SB_QFLAGS)) == 1410 XFS_SB_GQUOTINO | XFS_SB_QFLAGS)) ==
1411 (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | 1411 (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
1412 XFS_SB_GQUOTINO | XFS_SB_QFLAGS)); 1412 XFS_SB_GQUOTINO | XFS_SB_QFLAGS));
1413 1413
1414 XFS_SB_VERSION_ADDQUOTA(&mp->m_sb); 1414 xfs_sb_version_addquota(&mp->m_sb);
1415 mp->m_sb.sb_uquotino = NULLFSINO; 1415 mp->m_sb.sb_uquotino = NULLFSINO;
1416 mp->m_sb.sb_gquotino = NULLFSINO; 1416 mp->m_sb.sb_gquotino = NULLFSINO;
1417 1417
@@ -1954,7 +1954,7 @@ xfs_qm_init_quotainos(
1954 /* 1954 /*
1955 * Get the uquota and gquota inodes 1955 * Get the uquota and gquota inodes
1956 */ 1956 */
1957 if (XFS_SB_VERSION_HASQUOTA(&mp->m_sb)) { 1957 if (xfs_sb_version_hasquota(&mp->m_sb)) {
1958 if (XFS_IS_UQUOTA_ON(mp) && 1958 if (XFS_IS_UQUOTA_ON(mp) &&
1959 mp->m_sb.sb_uquotino != NULLFSINO) { 1959 mp->m_sb.sb_uquotino != NULLFSINO) {
1960 ASSERT(mp->m_sb.sb_uquotino > 0); 1960 ASSERT(mp->m_sb.sb_uquotino > 0);
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c
index 97bb32937585..f4f6c4c861d7 100644
--- a/fs/xfs/quota/xfs_qm_bhv.c
+++ b/fs/xfs/quota/xfs_qm_bhv.c
@@ -118,7 +118,7 @@ xfs_qm_newmount(
118 *quotaflags = 0; 118 *quotaflags = 0;
119 *needquotamount = B_FALSE; 119 *needquotamount = B_FALSE;
120 120
121 quotaondisk = XFS_SB_VERSION_HASQUOTA(&mp->m_sb) && 121 quotaondisk = xfs_sb_version_hasquota(&mp->m_sb) &&
122 (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT); 122 (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT);
123 123
124 if (quotaondisk) { 124 if (quotaondisk) {
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 2cc5886cfe85..d2b8be7e75f9 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -377,7 +377,7 @@ xfs_qm_scall_trunc_qfiles(
377 if (!capable(CAP_SYS_ADMIN)) 377 if (!capable(CAP_SYS_ADMIN))
378 return XFS_ERROR(EPERM); 378 return XFS_ERROR(EPERM);
379 error = 0; 379 error = 0;
380 if (!XFS_SB_VERSION_HASQUOTA(&mp->m_sb) || flags == 0) { 380 if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0) {
381 qdprintk("qtrunc flags=%x m_qflags=%x\n", flags, mp->m_qflags); 381 qdprintk("qtrunc flags=%x m_qflags=%x\n", flags, mp->m_qflags);
382 return XFS_ERROR(EINVAL); 382 return XFS_ERROR(EINVAL);
383 } 383 }
@@ -522,7 +522,7 @@ xfs_qm_scall_getqstat(
522 memset(out, 0, sizeof(fs_quota_stat_t)); 522 memset(out, 0, sizeof(fs_quota_stat_t));
523 523
524 out->qs_version = FS_QSTAT_VERSION; 524 out->qs_version = FS_QSTAT_VERSION;
525 if (! XFS_SB_VERSION_HASQUOTA(&mp->m_sb)) { 525 if (!xfs_sb_version_hasquota(&mp->m_sb)) {
526 out->qs_uquota.qfs_ino = NULLFSINO; 526 out->qs_uquota.qfs_ino = NULLFSINO;
527 out->qs_gquota.qfs_ino = NULLFSINO; 527 out->qs_gquota.qfs_ino = NULLFSINO;
528 return (0); 528 return (0);
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index b08e2a2a8add..96ba6aa4ed8c 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -227,10 +227,10 @@ STATIC void
227xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) 227xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp)
228{ 228{
229 if ((mp->m_flags & XFS_MOUNT_ATTR2) && 229 if ((mp->m_flags & XFS_MOUNT_ATTR2) &&
230 !(XFS_SB_VERSION_HASATTR2(&mp->m_sb))) { 230 !(xfs_sb_version_hasattr2(&mp->m_sb))) {
231 spin_lock(&mp->m_sb_lock); 231 spin_lock(&mp->m_sb_lock);
232 if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb)) { 232 if (!xfs_sb_version_hasattr2(&mp->m_sb)) {
233 XFS_SB_VERSION_ADDATTR2(&mp->m_sb); 233 xfs_sb_version_addattr2(&mp->m_sb);
234 spin_unlock(&mp->m_sb_lock); 234 spin_unlock(&mp->m_sb_lock);
235 xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); 235 xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
236 } else 236 } else
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 1c0a5a585a82..2def273855a2 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -4047,17 +4047,17 @@ xfs_bmap_add_attrfork(
4047 xfs_trans_log_inode(tp, ip, logflags); 4047 xfs_trans_log_inode(tp, ip, logflags);
4048 if (error) 4048 if (error)
4049 goto error2; 4049 goto error2;
4050 if (!XFS_SB_VERSION_HASATTR(&mp->m_sb) || 4050 if (!xfs_sb_version_hasattr(&mp->m_sb) ||
4051 (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2)) { 4051 (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) {
4052 __int64_t sbfields = 0; 4052 __int64_t sbfields = 0;
4053 4053
4054 spin_lock(&mp->m_sb_lock); 4054 spin_lock(&mp->m_sb_lock);
4055 if (!XFS_SB_VERSION_HASATTR(&mp->m_sb)) { 4055 if (!xfs_sb_version_hasattr(&mp->m_sb)) {
4056 XFS_SB_VERSION_ADDATTR(&mp->m_sb); 4056 xfs_sb_version_addattr(&mp->m_sb);
4057 sbfields |= XFS_SB_VERSIONNUM; 4057 sbfields |= XFS_SB_VERSIONNUM;
4058 } 4058 }
4059 if (!XFS_SB_VERSION_HASATTR2(&mp->m_sb) && version == 2) { 4059 if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) {
4060 XFS_SB_VERSION_ADDATTR2(&mp->m_sb); 4060 xfs_sb_version_addattr2(&mp->m_sb);
4061 sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); 4061 sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2);
4062 } 4062 }
4063 if (sbfields) { 4063 if (sbfields) {
@@ -5043,7 +5043,7 @@ xfs_bmapi(
5043 * A wasdelay extent has been initialized, so 5043 * A wasdelay extent has been initialized, so
5044 * shouldn't be flagged as unwritten. 5044 * shouldn't be flagged as unwritten.
5045 */ 5045 */
5046 if (wr && XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb)) { 5046 if (wr && xfs_sb_version_hasextflgbit(&mp->m_sb)) {
5047 if (!wasdelay && (flags & XFS_BMAPI_PREALLOC)) 5047 if (!wasdelay && (flags & XFS_BMAPI_PREALLOC))
5048 got.br_state = XFS_EXT_UNWRITTEN; 5048 got.br_state = XFS_EXT_UNWRITTEN;
5049 } 5049 }
@@ -5483,7 +5483,7 @@ xfs_bunmapi(
5483 * get rid of part of a realtime extent. 5483 * get rid of part of a realtime extent.
5484 */ 5484 */
5485 if (del.br_state == XFS_EXT_UNWRITTEN || 5485 if (del.br_state == XFS_EXT_UNWRITTEN ||
5486 !XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb)) { 5486 !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
5487 /* 5487 /*
5488 * This piece is unwritten, or we're not 5488 * This piece is unwritten, or we're not
5489 * using unwritten extents. Skip over it. 5489 * using unwritten extents. Skip over it.
@@ -5535,7 +5535,7 @@ xfs_bunmapi(
5535 } else if ((del.br_startoff == start && 5535 } else if ((del.br_startoff == start &&
5536 (del.br_state == XFS_EXT_UNWRITTEN || 5536 (del.br_state == XFS_EXT_UNWRITTEN ||
5537 xfs_trans_get_block_res(tp) == 0)) || 5537 xfs_trans_get_block_res(tp) == 0)) ||
5538 !XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb)) { 5538 !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
5539 /* 5539 /*
5540 * Can't make it unwritten. There isn't 5540 * Can't make it unwritten. There isn't
5541 * a full extent here so just skip it. 5541 * a full extent here so just skip it.
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 2d950e975918..cd0d4b4bb816 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -120,7 +120,7 @@ typedef enum {
120 * Extent state and extent format macros. 120 * Extent state and extent format macros.
121 */ 121 */
122#define XFS_EXTFMT_INODE(x) \ 122#define XFS_EXTFMT_INODE(x) \
123 (XFS_SB_VERSION_HASEXTFLGBIT(&((x)->i_mount->m_sb)) ? \ 123 (xfs_sb_version_hasextflgbit(&((x)->i_mount->m_sb)) ? \
124 XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE) 124 XFS_EXTFMT_HASSTATE : XFS_EXTFMT_NOSTATE)
125#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN) 125#define ISUNWRITTEN(x) ((x)->br_state == XFS_EXT_UNWRITTEN)
126 126
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index be7c4251fa61..e92e73f0e6af 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -49,7 +49,7 @@ void
49xfs_dir_mount( 49xfs_dir_mount(
50 xfs_mount_t *mp) 50 xfs_mount_t *mp)
51{ 51{
52 ASSERT(XFS_SB_VERSION_HASDIRV2(&mp->m_sb)); 52 ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
53 ASSERT((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) <= 53 ASSERT((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) <=
54 XFS_MAX_BLOCKSIZE); 54 XFS_MAX_BLOCKSIZE);
55 mp->m_dirblksize = 1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog); 55 mp->m_dirblksize = 1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog);
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index eadc1591c795..d3a0f538d6a6 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -77,36 +77,36 @@ xfs_fs_geometry(
77 if (new_version >= 3) { 77 if (new_version >= 3) {
78 geo->version = XFS_FSOP_GEOM_VERSION; 78 geo->version = XFS_FSOP_GEOM_VERSION;
79 geo->flags = 79 geo->flags =
80 (XFS_SB_VERSION_HASATTR(&mp->m_sb) ? 80 (xfs_sb_version_hasattr(&mp->m_sb) ?
81 XFS_FSOP_GEOM_FLAGS_ATTR : 0) | 81 XFS_FSOP_GEOM_FLAGS_ATTR : 0) |
82 (XFS_SB_VERSION_HASNLINK(&mp->m_sb) ? 82 (xfs_sb_version_hasnlink(&mp->m_sb) ?
83 XFS_FSOP_GEOM_FLAGS_NLINK : 0) | 83 XFS_FSOP_GEOM_FLAGS_NLINK : 0) |
84 (XFS_SB_VERSION_HASQUOTA(&mp->m_sb) ? 84 (xfs_sb_version_hasquota(&mp->m_sb) ?
85 XFS_FSOP_GEOM_FLAGS_QUOTA : 0) | 85 XFS_FSOP_GEOM_FLAGS_QUOTA : 0) |
86 (XFS_SB_VERSION_HASALIGN(&mp->m_sb) ? 86 (xfs_sb_version_hasalign(&mp->m_sb) ?
87 XFS_FSOP_GEOM_FLAGS_IALIGN : 0) | 87 XFS_FSOP_GEOM_FLAGS_IALIGN : 0) |
88 (XFS_SB_VERSION_HASDALIGN(&mp->m_sb) ? 88 (xfs_sb_version_hasdalign(&mp->m_sb) ?
89 XFS_FSOP_GEOM_FLAGS_DALIGN : 0) | 89 XFS_FSOP_GEOM_FLAGS_DALIGN : 0) |
90 (XFS_SB_VERSION_HASSHARED(&mp->m_sb) ? 90 (xfs_sb_version_hasshared(&mp->m_sb) ?
91 XFS_FSOP_GEOM_FLAGS_SHARED : 0) | 91 XFS_FSOP_GEOM_FLAGS_SHARED : 0) |
92 (XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) ? 92 (xfs_sb_version_hasextflgbit(&mp->m_sb) ?
93 XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) | 93 XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) |
94 (XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ? 94 (xfs_sb_version_hasdirv2(&mp->m_sb) ?
95 XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) | 95 XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) |
96 (XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? 96 (xfs_sb_version_hassector(&mp->m_sb) ?
97 XFS_FSOP_GEOM_FLAGS_SECTOR : 0) | 97 XFS_FSOP_GEOM_FLAGS_SECTOR : 0) |
98 (xfs_sb_version_haslazysbcount(&mp->m_sb) ? 98 (xfs_sb_version_haslazysbcount(&mp->m_sb) ?
99 XFS_FSOP_GEOM_FLAGS_LAZYSB : 0) | 99 XFS_FSOP_GEOM_FLAGS_LAZYSB : 0) |
100 (XFS_SB_VERSION_HASATTR2(&mp->m_sb) ? 100 (xfs_sb_version_hasattr2(&mp->m_sb) ?
101 XFS_FSOP_GEOM_FLAGS_ATTR2 : 0); 101 XFS_FSOP_GEOM_FLAGS_ATTR2 : 0);
102 geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ? 102 geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ?
103 mp->m_sb.sb_logsectsize : BBSIZE; 103 mp->m_sb.sb_logsectsize : BBSIZE;
104 geo->rtsectsize = mp->m_sb.sb_blocksize; 104 geo->rtsectsize = mp->m_sb.sb_blocksize;
105 geo->dirblocksize = mp->m_dirblksize; 105 geo->dirblocksize = mp->m_dirblksize;
106 } 106 }
107 if (new_version >= 4) { 107 if (new_version >= 4) {
108 geo->flags |= 108 geo->flags |=
109 (XFS_SB_VERSION_HASLOGV2(&mp->m_sb) ? 109 (xfs_sb_version_haslogv2(&mp->m_sb) ?
110 XFS_FSOP_GEOM_FLAGS_LOGV2 : 0); 110 XFS_FSOP_GEOM_FLAGS_LOGV2 : 0);
111 geo->logsunit = mp->m_sb.sb_logsunit; 111 geo->logsunit = mp->m_sb.sb_logsunit;
112 } 112 }
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index db9d5fa600af..5a146cb22980 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -191,7 +191,7 @@ xfs_ialloc_ag_alloc(
191 ASSERT(!(args.mp->m_flags & XFS_MOUNT_NOALIGN)); 191 ASSERT(!(args.mp->m_flags & XFS_MOUNT_NOALIGN));
192 args.alignment = args.mp->m_dalign; 192 args.alignment = args.mp->m_dalign;
193 isaligned = 1; 193 isaligned = 1;
194 } else if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && 194 } else if (xfs_sb_version_hasalign(&args.mp->m_sb) &&
195 args.mp->m_sb.sb_inoalignmt >= 195 args.mp->m_sb.sb_inoalignmt >=
196 XFS_B_TO_FSBT(args.mp, 196 XFS_B_TO_FSBT(args.mp,
197 XFS_INODE_CLUSTER_SIZE(args.mp))) 197 XFS_INODE_CLUSTER_SIZE(args.mp)))
@@ -230,7 +230,7 @@ xfs_ialloc_ag_alloc(
230 args.agbno = be32_to_cpu(agi->agi_root); 230 args.agbno = be32_to_cpu(agi->agi_root);
231 args.fsbno = XFS_AGB_TO_FSB(args.mp, 231 args.fsbno = XFS_AGB_TO_FSB(args.mp,
232 be32_to_cpu(agi->agi_seqno), args.agbno); 232 be32_to_cpu(agi->agi_seqno), args.agbno);
233 if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && 233 if (xfs_sb_version_hasalign(&args.mp->m_sb) &&
234 args.mp->m_sb.sb_inoalignmt >= 234 args.mp->m_sb.sb_inoalignmt >=
235 XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp))) 235 XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp)))
236 args.alignment = args.mp->m_sb.sb_inoalignmt; 236 args.alignment = args.mp->m_sb.sb_inoalignmt;
@@ -271,7 +271,7 @@ xfs_ialloc_ag_alloc(
271 * use the old version so that old kernels will continue to be 271 * use the old version so that old kernels will continue to be
272 * able to use the file system. 272 * able to use the file system.
273 */ 273 */
274 if (XFS_SB_VERSION_HASNLINK(&args.mp->m_sb)) 274 if (xfs_sb_version_hasnlink(&args.mp->m_sb))
275 version = XFS_DINODE_VERSION_2; 275 version = XFS_DINODE_VERSION_2;
276 else 276 else
277 version = XFS_DINODE_VERSION_1; 277 version = XFS_DINODE_VERSION_1;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index a550546a7083..f43a6e01d68f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1147,7 +1147,7 @@ xfs_ialloc(
1147 * the inode version number now. This way we only do the conversion 1147 * the inode version number now. This way we only do the conversion
1148 * here rather than here and in the flush/logging code. 1148 * here rather than here and in the flush/logging code.
1149 */ 1149 */
1150 if (XFS_SB_VERSION_HASNLINK(&tp->t_mountp->m_sb) && 1150 if (xfs_sb_version_hasnlink(&tp->t_mountp->m_sb) &&
1151 ip->i_d.di_version == XFS_DINODE_VERSION_1) { 1151 ip->i_d.di_version == XFS_DINODE_VERSION_1) {
1152 ip->i_d.di_version = XFS_DINODE_VERSION_2; 1152 ip->i_d.di_version = XFS_DINODE_VERSION_2;
1153 /* 1153 /*
@@ -3434,9 +3434,9 @@ xfs_iflush_int(
3434 * has been updated, then make the conversion permanent. 3434 * has been updated, then make the conversion permanent.
3435 */ 3435 */
3436 ASSERT(ip->i_d.di_version == XFS_DINODE_VERSION_1 || 3436 ASSERT(ip->i_d.di_version == XFS_DINODE_VERSION_1 ||
3437 XFS_SB_VERSION_HASNLINK(&mp->m_sb)); 3437 xfs_sb_version_hasnlink(&mp->m_sb));
3438 if (ip->i_d.di_version == XFS_DINODE_VERSION_1) { 3438 if (ip->i_d.di_version == XFS_DINODE_VERSION_1) {
3439 if (!XFS_SB_VERSION_HASNLINK(&mp->m_sb)) { 3439 if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
3440 /* 3440 /*
3441 * Convert it back. 3441 * Convert it back.
3442 */ 3442 */
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 034ca7202295..2c775b4ae9e6 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -296,9 +296,9 @@ xfs_inode_item_format(
296 */ 296 */
297 mp = ip->i_mount; 297 mp = ip->i_mount;
298 ASSERT(ip->i_d.di_version == XFS_DINODE_VERSION_1 || 298 ASSERT(ip->i_d.di_version == XFS_DINODE_VERSION_1 ||
299 XFS_SB_VERSION_HASNLINK(&mp->m_sb)); 299 xfs_sb_version_hasnlink(&mp->m_sb));
300 if (ip->i_d.di_version == XFS_DINODE_VERSION_1) { 300 if (ip->i_d.di_version == XFS_DINODE_VERSION_1) {
301 if (!XFS_SB_VERSION_HASNLINK(&mp->m_sb)) { 301 if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
302 /* 302 /*
303 * Convert it back. 303 * Convert it back.
304 */ 304 */
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 658aab6b1bbf..f615e04364f4 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -45,7 +45,7 @@ xfs_internal_inum(
45 xfs_ino_t ino) 45 xfs_ino_t ino)
46{ 46{
47 return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || 47 return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino ||
48 (XFS_SB_VERSION_HASQUOTA(&mp->m_sb) && 48 (xfs_sb_version_hasquota(&mp->m_sb) &&
49 (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino))); 49 (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino)));
50} 50}
51 51
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index a75edca1860f..31f2b04f2c97 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1090,7 +1090,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp,
1090 size >>= 1; 1090 size >>= 1;
1091 } 1091 }
1092 1092
1093 if (XFS_SB_VERSION_HASLOGV2(&mp->m_sb)) { 1093 if (xfs_sb_version_haslogv2(&mp->m_sb)) {
1094 /* # headers = size / 32K 1094 /* # headers = size / 32K
1095 * one header holds cycles from 32K of data 1095 * one header holds cycles from 32K of data
1096 */ 1096 */
@@ -1186,13 +1186,13 @@ xlog_alloc_log(xfs_mount_t *mp,
1186 log->l_grant_reserve_cycle = 1; 1186 log->l_grant_reserve_cycle = 1;
1187 log->l_grant_write_cycle = 1; 1187 log->l_grant_write_cycle = 1;
1188 1188
1189 if (XFS_SB_VERSION_HASSECTOR(&mp->m_sb)) { 1189 if (xfs_sb_version_hassector(&mp->m_sb)) {
1190 log->l_sectbb_log = mp->m_sb.sb_logsectlog - BBSHIFT; 1190 log->l_sectbb_log = mp->m_sb.sb_logsectlog - BBSHIFT;
1191 ASSERT(log->l_sectbb_log <= mp->m_sectbb_log); 1191 ASSERT(log->l_sectbb_log <= mp->m_sectbb_log);
1192 /* for larger sector sizes, must have v2 or external log */ 1192 /* for larger sector sizes, must have v2 or external log */
1193 ASSERT(log->l_sectbb_log == 0 || 1193 ASSERT(log->l_sectbb_log == 0 ||
1194 log->l_logBBstart == 0 || 1194 log->l_logBBstart == 0 ||
1195 XFS_SB_VERSION_HASLOGV2(&mp->m_sb)); 1195 xfs_sb_version_haslogv2(&mp->m_sb));
1196 ASSERT(mp->m_sb.sb_logsectlog >= BBSHIFT); 1196 ASSERT(mp->m_sb.sb_logsectlog >= BBSHIFT);
1197 } 1197 }
1198 log->l_sectbb_mask = (1 << log->l_sectbb_log) - 1; 1198 log->l_sectbb_mask = (1 << log->l_sectbb_log) - 1;
@@ -1247,7 +1247,7 @@ xlog_alloc_log(xfs_mount_t *mp,
1247 memset(head, 0, sizeof(xlog_rec_header_t)); 1247 memset(head, 0, sizeof(xlog_rec_header_t));
1248 head->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM); 1248 head->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM);
1249 head->h_version = cpu_to_be32( 1249 head->h_version = cpu_to_be32(
1250 XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? 2 : 1); 1250 xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? 2 : 1);
1251 head->h_size = cpu_to_be32(log->l_iclog_size); 1251 head->h_size = cpu_to_be32(log->l_iclog_size);
1252 /* new fields */ 1252 /* new fields */
1253 head->h_fmt = cpu_to_be32(XLOG_FMT); 1253 head->h_fmt = cpu_to_be32(XLOG_FMT);
@@ -1402,7 +1402,7 @@ xlog_sync(xlog_t *log,
1402 int roundoff; /* roundoff to BB or stripe */ 1402 int roundoff; /* roundoff to BB or stripe */
1403 int split = 0; /* split write into two regions */ 1403 int split = 0; /* split write into two regions */
1404 int error; 1404 int error;
1405 int v2 = XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb); 1405 int v2 = xfs_sb_version_haslogv2(&log->l_mp->m_sb);
1406 1406
1407 XFS_STATS_INC(xs_log_writes); 1407 XFS_STATS_INC(xs_log_writes);
1408 ASSERT(iclog->ic_refcnt == 0); 1408 ASSERT(iclog->ic_refcnt == 0);
@@ -2881,7 +2881,7 @@ xlog_state_switch_iclogs(xlog_t *log,
2881 log->l_curr_block += BTOBB(eventual_size)+BTOBB(log->l_iclog_hsize); 2881 log->l_curr_block += BTOBB(eventual_size)+BTOBB(log->l_iclog_hsize);
2882 2882
2883 /* Round up to next log-sunit */ 2883 /* Round up to next log-sunit */
2884 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) && 2884 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb) &&
2885 log->l_mp->m_sb.sb_logsunit > 1) { 2885 log->l_mp->m_sb.sb_logsunit > 1) {
2886 __uint32_t sunit_bb = BTOBB(log->l_mp->m_sb.sb_logsunit); 2886 __uint32_t sunit_bb = BTOBB(log->l_mp->m_sb.sb_logsunit);
2887 log->l_curr_block = roundup(log->l_curr_block, sunit_bb); 2887 log->l_curr_block = roundup(log->l_curr_block, sunit_bb);
@@ -3334,7 +3334,7 @@ xlog_ticket_get(xlog_t *log,
3334 unit_bytes += sizeof(xlog_op_header_t) * num_headers; 3334 unit_bytes += sizeof(xlog_op_header_t) * num_headers;
3335 3335
3336 /* for roundoff padding for transaction data and one for commit record */ 3336 /* for roundoff padding for transaction data and one for commit record */
3337 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) && 3337 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb) &&
3338 log->l_mp->m_sb.sb_logsunit > 1) { 3338 log->l_mp->m_sb.sb_logsunit > 1) {
3339 /* log su roundoff */ 3339 /* log su roundoff */
3340 unit_bytes += 2*log->l_mp->m_sb.sb_logsunit; 3340 unit_bytes += 2*log->l_mp->m_sb.sb_logsunit;
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index e008233ee249..c6244cc733c0 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -49,10 +49,10 @@ struct xfs_mount;
49#define XLOG_HEADER_SIZE 512 49#define XLOG_HEADER_SIZE 512
50 50
51#define XLOG_REC_SHIFT(log) \ 51#define XLOG_REC_SHIFT(log) \
52 BTOBB(1 << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \ 52 BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
53 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) 53 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
54#define XLOG_TOTAL_REC_SHIFT(log) \ 54#define XLOG_TOTAL_REC_SHIFT(log) \
55 BTOBB(XLOG_MAX_ICLOGS << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \ 55 BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
56 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) 56 XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
57 57
58 58
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index b82d5d4d2462..b2b70eba282c 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -478,7 +478,7 @@ xlog_find_verify_log_record(
478 * reset last_blk. Only when last_blk points in the middle of a log 478 * reset last_blk. Only when last_blk points in the middle of a log
479 * record do we update last_blk. 479 * record do we update last_blk.
480 */ 480 */
481 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { 481 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
482 uint h_size = be32_to_cpu(head->h_size); 482 uint h_size = be32_to_cpu(head->h_size);
483 483
484 xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE; 484 xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE;
@@ -888,7 +888,7 @@ xlog_find_tail(
888 * unmount record if there is one, so we pass the lsn of the 888 * unmount record if there is one, so we pass the lsn of the
889 * unmount record rather than the block after it. 889 * unmount record rather than the block after it.
890 */ 890 */
891 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { 891 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
892 int h_size = be32_to_cpu(rhead->h_size); 892 int h_size = be32_to_cpu(rhead->h_size);
893 int h_version = be32_to_cpu(rhead->h_version); 893 int h_version = be32_to_cpu(rhead->h_version);
894 894
@@ -1101,7 +1101,7 @@ xlog_add_record(
1101 recp->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM); 1101 recp->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM);
1102 recp->h_cycle = cpu_to_be32(cycle); 1102 recp->h_cycle = cpu_to_be32(cycle);
1103 recp->h_version = cpu_to_be32( 1103 recp->h_version = cpu_to_be32(
1104 XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? 2 : 1); 1104 xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? 2 : 1);
1105 recp->h_lsn = cpu_to_be64(xlog_assign_lsn(cycle, block)); 1105 recp->h_lsn = cpu_to_be64(xlog_assign_lsn(cycle, block));
1106 recp->h_tail_lsn = cpu_to_be64(xlog_assign_lsn(tail_cycle, tail_block)); 1106 recp->h_tail_lsn = cpu_to_be64(xlog_assign_lsn(tail_cycle, tail_block));
1107 recp->h_fmt = cpu_to_be32(XLOG_FMT); 1107 recp->h_fmt = cpu_to_be32(XLOG_FMT);
@@ -3348,7 +3348,7 @@ xlog_pack_data(
3348 dp += BBSIZE; 3348 dp += BBSIZE;
3349 } 3349 }
3350 3350
3351 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { 3351 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
3352 xhdr = (xlog_in_core_2_t *)&iclog->ic_header; 3352 xhdr = (xlog_in_core_2_t *)&iclog->ic_header;
3353 for ( ; i < BTOBB(size); i++) { 3353 for ( ; i < BTOBB(size); i++) {
3354 j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); 3354 j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
@@ -3388,7 +3388,7 @@ xlog_unpack_data_checksum(
3388 be32_to_cpu(rhead->h_chksum), chksum); 3388 be32_to_cpu(rhead->h_chksum), chksum);
3389 cmn_err(CE_DEBUG, 3389 cmn_err(CE_DEBUG,
3390"XFS: Disregard message if filesystem was created with non-DEBUG kernel"); 3390"XFS: Disregard message if filesystem was created with non-DEBUG kernel");
3391 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { 3391 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
3392 cmn_err(CE_DEBUG, 3392 cmn_err(CE_DEBUG,
3393 "XFS: LogR this is a LogV2 filesystem\n"); 3393 "XFS: LogR this is a LogV2 filesystem\n");
3394 } 3394 }
@@ -3415,7 +3415,7 @@ xlog_unpack_data(
3415 dp += BBSIZE; 3415 dp += BBSIZE;
3416 } 3416 }
3417 3417
3418 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { 3418 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
3419 xhdr = (xlog_in_core_2_t *)rhead; 3419 xhdr = (xlog_in_core_2_t *)rhead;
3420 for ( ; i < BTOBB(be32_to_cpu(rhead->h_len)); i++) { 3420 for ( ; i < BTOBB(be32_to_cpu(rhead->h_len)); i++) {
3421 j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); 3421 j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
@@ -3494,7 +3494,7 @@ xlog_do_recovery_pass(
3494 * Read the header of the tail block and get the iclog buffer size from 3494 * Read the header of the tail block and get the iclog buffer size from
3495 * h_size. Use this to tell how many sectors make up the log header. 3495 * h_size. Use this to tell how many sectors make up the log header.
3496 */ 3496 */
3497 if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) { 3497 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
3498 /* 3498 /*
3499 * When using variable length iclogs, read first sector of 3499 * When using variable length iclogs, read first sector of
3500 * iclog header and extract the header size from it. Get a 3500 * iclog header and extract the header size from it. Get a
@@ -3838,7 +3838,7 @@ xlog_do_recover(
3838 sbp = &log->l_mp->m_sb; 3838 sbp = &log->l_mp->m_sb;
3839 xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp)); 3839 xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp));
3840 ASSERT(sbp->sb_magicnum == XFS_SB_MAGIC); 3840 ASSERT(sbp->sb_magicnum == XFS_SB_MAGIC);
3841 ASSERT(XFS_SB_GOOD_VERSION(sbp)); 3841 ASSERT(xfs_sb_good_version(sbp));
3842 xfs_buf_relse(bp); 3842 xfs_buf_relse(bp);
3843 3843
3844 /* We've re-read the superblock so re-initialize per-cpu counters */ 3844 /* We've re-read the superblock so re-initialize per-cpu counters */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 6409b3762995..8ed164eb9544 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -44,7 +44,7 @@
44#include "xfs_quota.h" 44#include "xfs_quota.h"
45#include "xfs_fsops.h" 45#include "xfs_fsops.h"
46 46
47STATIC void xfs_mount_log_sbunit(xfs_mount_t *, __int64_t); 47STATIC void xfs_mount_log_sb(xfs_mount_t *, __int64_t);
48STATIC int xfs_uuid_mount(xfs_mount_t *); 48STATIC int xfs_uuid_mount(xfs_mount_t *);
49STATIC void xfs_uuid_unmount(xfs_mount_t *mp); 49STATIC void xfs_uuid_unmount(xfs_mount_t *mp);
50STATIC void xfs_unmountfs_wait(xfs_mount_t *); 50STATIC void xfs_unmountfs_wait(xfs_mount_t *);
@@ -119,6 +119,7 @@ static const struct {
119 { offsetof(xfs_sb_t, sb_logsectsize),0 }, 119 { offsetof(xfs_sb_t, sb_logsectsize),0 },
120 { offsetof(xfs_sb_t, sb_logsunit), 0 }, 120 { offsetof(xfs_sb_t, sb_logsunit), 0 },
121 { offsetof(xfs_sb_t, sb_features2), 0 }, 121 { offsetof(xfs_sb_t, sb_features2), 0 },
122 { offsetof(xfs_sb_t, sb_bad_features2), 0 },
122 { sizeof(xfs_sb_t), 0 } 123 { sizeof(xfs_sb_t), 0 }
123}; 124};
124 125
@@ -225,7 +226,7 @@ xfs_mount_validate_sb(
225 return XFS_ERROR(EWRONGFS); 226 return XFS_ERROR(EWRONGFS);
226 } 227 }
227 228
228 if (!XFS_SB_GOOD_VERSION(sbp)) { 229 if (!xfs_sb_good_version(sbp)) {
229 xfs_fs_mount_cmn_err(flags, "bad version"); 230 xfs_fs_mount_cmn_err(flags, "bad version");
230 return XFS_ERROR(EWRONGFS); 231 return XFS_ERROR(EWRONGFS);
231 } 232 }
@@ -300,7 +301,7 @@ xfs_mount_validate_sb(
300 /* 301 /*
301 * Version 1 directory format has never worked on Linux. 302 * Version 1 directory format has never worked on Linux.
302 */ 303 */
303 if (unlikely(!XFS_SB_VERSION_HASDIRV2(sbp))) { 304 if (unlikely(!xfs_sb_version_hasdirv2(sbp))) {
304 xfs_fs_mount_cmn_err(flags, 305 xfs_fs_mount_cmn_err(flags,
305 "file system using version 1 directory format"); 306 "file system using version 1 directory format");
306 return XFS_ERROR(ENOSYS); 307 return XFS_ERROR(ENOSYS);
@@ -449,6 +450,7 @@ xfs_sb_from_disk(
449 to->sb_logsectsize = be16_to_cpu(from->sb_logsectsize); 450 to->sb_logsectsize = be16_to_cpu(from->sb_logsectsize);
450 to->sb_logsunit = be32_to_cpu(from->sb_logsunit); 451 to->sb_logsunit = be32_to_cpu(from->sb_logsunit);
451 to->sb_features2 = be32_to_cpu(from->sb_features2); 452 to->sb_features2 = be32_to_cpu(from->sb_features2);
453 to->sb_bad_features2 = be32_to_cpu(from->sb_bad_features2);
452} 454}
453 455
454/* 456/*
@@ -781,7 +783,7 @@ xfs_update_alignment(xfs_mount_t *mp, int mfsi_flags, __uint64_t *update_flags)
781 * Update superblock with new values 783 * Update superblock with new values
782 * and log changes 784 * and log changes
783 */ 785 */
784 if (XFS_SB_VERSION_HASDALIGN(sbp)) { 786 if (xfs_sb_version_hasdalign(sbp)) {
785 if (sbp->sb_unit != mp->m_dalign) { 787 if (sbp->sb_unit != mp->m_dalign) {
786 sbp->sb_unit = mp->m_dalign; 788 sbp->sb_unit = mp->m_dalign;
787 *update_flags |= XFS_SB_UNIT; 789 *update_flags |= XFS_SB_UNIT;
@@ -792,7 +794,7 @@ xfs_update_alignment(xfs_mount_t *mp, int mfsi_flags, __uint64_t *update_flags)
792 } 794 }
793 } 795 }
794 } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN && 796 } else if ((mp->m_flags & XFS_MOUNT_NOALIGN) != XFS_MOUNT_NOALIGN &&
795 XFS_SB_VERSION_HASDALIGN(&mp->m_sb)) { 797 xfs_sb_version_hasdalign(&mp->m_sb)) {
796 mp->m_dalign = sbp->sb_unit; 798 mp->m_dalign = sbp->sb_unit;
797 mp->m_swidth = sbp->sb_width; 799 mp->m_swidth = sbp->sb_width;
798 } 800 }
@@ -869,7 +871,7 @@ xfs_set_rw_sizes(xfs_mount_t *mp)
869STATIC void 871STATIC void
870xfs_set_inoalignment(xfs_mount_t *mp) 872xfs_set_inoalignment(xfs_mount_t *mp)
871{ 873{
872 if (XFS_SB_VERSION_HASALIGN(&mp->m_sb) && 874 if (xfs_sb_version_hasalign(&mp->m_sb) &&
873 mp->m_sb.sb_inoalignmt >= 875 mp->m_sb.sb_inoalignmt >=
874 XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size)) 876 XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size))
875 mp->m_inoalign_mask = mp->m_sb.sb_inoalignmt - 1; 877 mp->m_inoalign_mask = mp->m_sb.sb_inoalignmt - 1;
@@ -970,6 +972,38 @@ xfs_mountfs(
970 xfs_mount_common(mp, sbp); 972 xfs_mount_common(mp, sbp);
971 973
972 /* 974 /*
975 * Check for a mismatched features2 values. Older kernels
976 * read & wrote into the wrong sb offset for sb_features2
977 * on some platforms due to xfs_sb_t not being 64bit size aligned
978 * when sb_features2 was added, which made older superblock
979 * reading/writing routines swap it as a 64-bit value.
980 *
981 * For backwards compatibility, we make both slots equal.
982 *
983 * If we detect a mismatched field, we OR the set bits into the
984 * existing features2 field in case it has already been modified; we
985 * don't want to lose any features. We then update the bad location
986 * with the ORed value so that older kernels will see any features2
987 * flags, and mark the two fields as needing updates once the
988 * transaction subsystem is online.
989 */
990 if (xfs_sb_has_mismatched_features2(sbp)) {
991 cmn_err(CE_WARN,
992 "XFS: correcting sb_features alignment problem");
993 sbp->sb_features2 |= sbp->sb_bad_features2;
994 sbp->sb_bad_features2 = sbp->sb_features2;
995 update_flags |= XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2;
996
997 /*
998 * Re-check for ATTR2 in case it was found in bad_features2
999 * slot.
1000 */
1001 if (xfs_sb_version_hasattr2(&mp->m_sb))
1002 mp->m_flags |= XFS_MOUNT_ATTR2;
1003
1004 }
1005
1006 /*
973 * Check if sb_agblocks is aligned at stripe boundary 1007 * Check if sb_agblocks is aligned at stripe boundary
974 * If sb_agblocks is NOT aligned turn off m_dalign since 1008 * If sb_agblocks is NOT aligned turn off m_dalign since
975 * allocator alignment is within an ag, therefore ag has 1009 * allocator alignment is within an ag, therefore ag has
@@ -1159,11 +1193,10 @@ xfs_mountfs(
1159 } 1193 }
1160 1194
1161 /* 1195 /*
1162 * If fs is not mounted readonly, then update the superblock 1196 * If fs is not mounted readonly, then update the superblock changes.
1163 * unit and width changes.
1164 */ 1197 */
1165 if (update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY)) 1198 if (update_flags && !(mp->m_flags & XFS_MOUNT_RDONLY))
1166 xfs_mount_log_sbunit(mp, update_flags); 1199 xfs_mount_log_sb(mp, update_flags);
1167 1200
1168 /* 1201 /*
1169 * Initialise the XFS quota management subsystem for this mount 1202 * Initialise the XFS quota management subsystem for this mount
@@ -1875,16 +1908,18 @@ xfs_uuid_unmount(
1875 1908
1876/* 1909/*
1877 * Used to log changes to the superblock unit and width fields which could 1910 * Used to log changes to the superblock unit and width fields which could
1878 * be altered by the mount options. Only the first superblock is updated. 1911 * be altered by the mount options, as well as any potential sb_features2
1912 * fixup. Only the first superblock is updated.
1879 */ 1913 */
1880STATIC void 1914STATIC void
1881xfs_mount_log_sbunit( 1915xfs_mount_log_sb(
1882 xfs_mount_t *mp, 1916 xfs_mount_t *mp,
1883 __int64_t fields) 1917 __int64_t fields)
1884{ 1918{
1885 xfs_trans_t *tp; 1919 xfs_trans_t *tp;
1886 1920
1887 ASSERT(fields & (XFS_SB_UNIT|XFS_SB_WIDTH|XFS_SB_UUID)); 1921 ASSERT(fields & (XFS_SB_UNIT | XFS_SB_WIDTH | XFS_SB_UUID |
1922 XFS_SB_FEATURES2 | XFS_SB_BAD_FEATURES2));
1888 1923
1889 tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT); 1924 tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT);
1890 if (xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0, 1925 if (xfs_trans_reserve(tp, 0, mp->m_sb.sb_sectsize + 128, 0, 0,
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index 94660b1a6ccc..d904efe7f871 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -89,6 +89,7 @@ struct xfs_mount;
89 89
90/* 90/*
91 * Superblock - in core version. Must match the ondisk version below. 91 * Superblock - in core version. Must match the ondisk version below.
92 * Must be padded to 64 bit alignment.
92 */ 93 */
93typedef struct xfs_sb { 94typedef struct xfs_sb {
94 __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ 95 __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
@@ -145,10 +146,21 @@ typedef struct xfs_sb {
145 __uint16_t sb_logsectsize; /* sector size for the log, bytes */ 146 __uint16_t sb_logsectsize; /* sector size for the log, bytes */
146 __uint32_t sb_logsunit; /* stripe unit size for the log */ 147 __uint32_t sb_logsunit; /* stripe unit size for the log */
147 __uint32_t sb_features2; /* additional feature bits */ 148 __uint32_t sb_features2; /* additional feature bits */
149
150 /*
151 * bad features2 field as a result of failing to pad the sb
152 * structure to 64 bits. Some machines will be using this field
153 * for features2 bits. Easiest just to mark it bad and not use
154 * it for anything else.
155 */
156 __uint32_t sb_bad_features2;
157
158 /* must be padded to 64 bit alignment */
148} xfs_sb_t; 159} xfs_sb_t;
149 160
150/* 161/*
151 * Superblock - on disk version. Must match the in core version below. 162 * Superblock - on disk version. Must match the in core version above.
163 * Must be padded to 64 bit alignment.
152 */ 164 */
153typedef struct xfs_dsb { 165typedef struct xfs_dsb {
154 __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ 166 __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */
@@ -205,6 +217,15 @@ typedef struct xfs_dsb {
205 __be16 sb_logsectsize; /* sector size for the log, bytes */ 217 __be16 sb_logsectsize; /* sector size for the log, bytes */
206 __be32 sb_logsunit; /* stripe unit size for the log */ 218 __be32 sb_logsunit; /* stripe unit size for the log */
207 __be32 sb_features2; /* additional feature bits */ 219 __be32 sb_features2; /* additional feature bits */
220 /*
221 * bad features2 field as a result of failing to pad the sb
222 * structure to 64 bits. Some machines will be using this field
223 * for features2 bits. Easiest just to mark it bad and not use
224 * it for anything else.
225 */
226 __be32 sb_bad_features2;
227
228 /* must be padded to 64 bit alignment */
208} xfs_dsb_t; 229} xfs_dsb_t;
209 230
210/* 231/*
@@ -223,7 +244,7 @@ typedef enum {
223 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, 244 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN,
224 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, 245 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
225 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, 246 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
226 XFS_SBS_FEATURES2, 247 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2,
227 XFS_SBS_FIELDCOUNT 248 XFS_SBS_FIELDCOUNT
228} xfs_sb_field_t; 249} xfs_sb_field_t;
229 250
@@ -248,13 +269,15 @@ typedef enum {
248#define XFS_SB_IFREE XFS_SB_MVAL(IFREE) 269#define XFS_SB_IFREE XFS_SB_MVAL(IFREE)
249#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) 270#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
250#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) 271#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
272#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
251#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) 273#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
252#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) 274#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
253#define XFS_SB_MOD_BITS \ 275#define XFS_SB_MOD_BITS \
254 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ 276 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
255 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ 277 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
256 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ 278 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
257 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2) 279 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
280 XFS_SB_BAD_FEATURES2)
258 281
259 282
260/* 283/*
@@ -271,7 +294,6 @@ typedef enum {
271 294
272#define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) 295#define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
273 296
274#define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp)
275#ifdef __KERNEL__ 297#ifdef __KERNEL__
276static inline int xfs_sb_good_version(xfs_sb_t *sbp) 298static inline int xfs_sb_good_version(xfs_sb_t *sbp)
277{ 299{
@@ -297,7 +319,15 @@ static inline int xfs_sb_good_version(xfs_sb_t *sbp)
297} 319}
298#endif /* __KERNEL__ */ 320#endif /* __KERNEL__ */
299 321
300#define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v) 322/*
323 * Detect a mismatched features2 field. Older kernels read/wrote
324 * this into the wrong slot, so to be safe we keep them in sync.
325 */
326static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp)
327{
328 return (sbp->sb_bad_features2 != sbp->sb_features2);
329}
330
301static inline unsigned xfs_sb_version_tonew(unsigned v) 331static inline unsigned xfs_sb_version_tonew(unsigned v)
302{ 332{
303 return ((((v) == XFS_SB_VERSION_1) ? \ 333 return ((((v) == XFS_SB_VERSION_1) ? \
@@ -308,7 +338,6 @@ static inline unsigned xfs_sb_version_tonew(unsigned v)
308 XFS_SB_VERSION_4); 338 XFS_SB_VERSION_4);
309} 339}
310 340
311#define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v)
312static inline unsigned xfs_sb_version_toold(unsigned v) 341static inline unsigned xfs_sb_version_toold(unsigned v)
313{ 342{
314 return (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \ 343 return (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \
@@ -320,7 +349,6 @@ static inline unsigned xfs_sb_version_toold(unsigned v)
320 XFS_SB_VERSION_1))); 349 XFS_SB_VERSION_1)));
321} 350}
322 351
323#define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp)
324static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp) 352static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
325{ 353{
326 return ((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \ 354 return ((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \
@@ -329,7 +357,6 @@ static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
329 ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); 357 ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
330} 358}
331 359
332#define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp)
333static inline void xfs_sb_version_addattr(xfs_sb_t *sbp) 360static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
334{ 361{
335 (sbp)->sb_versionnum = (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \ 362 (sbp)->sb_versionnum = (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \
@@ -339,7 +366,6 @@ static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
339 (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT))); 366 (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT)));
340} 367}
341 368
342#define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp)
343static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) 369static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
344{ 370{
345 return ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \ 371 return ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
@@ -347,7 +373,6 @@ static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
347 ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); 373 ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
348} 374}
349 375
350#define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp)
351static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp) 376static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
352{ 377{
353 (sbp)->sb_versionnum = ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \ 378 (sbp)->sb_versionnum = ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \
@@ -355,115 +380,63 @@ static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
355 ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT)); 380 ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT));
356} 381}
357 382
358#define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp)
359static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) 383static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
360{ 384{
361 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 385 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
362 ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT); 386 ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
363} 387}
364 388
365#define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp)
366static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) 389static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
367{ 390{
368 (sbp)->sb_versionnum = \ 391 (sbp)->sb_versionnum = \
369 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \ 392 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \
370 ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \ 393 ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \
371 (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \ 394 (xfs_sb_version_tonew((sbp)->sb_versionnum) | \
372 XFS_SB_VERSION_QUOTABIT)); 395 XFS_SB_VERSION_QUOTABIT));
373} 396}
374 397
375#define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp)
376static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) 398static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
377{ 399{
378 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 400 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
379 ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); 401 ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT);
380} 402}
381 403
382#define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp)
383static inline void xfs_sb_version_subalign(xfs_sb_t *sbp)
384{
385 (sbp)->sb_versionnum = \
386 XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT);
387}
388
389#define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp)
390static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) 404static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
391{ 405{
392 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 406 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
393 ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); 407 ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
394} 408}
395 409
396#define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp)
397static inline int xfs_sb_version_adddalign(xfs_sb_t *sbp)
398{
399 return (sbp)->sb_versionnum = \
400 ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT);
401}
402
403#define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp)
404static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp) 410static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
405{ 411{
406 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 412 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
407 ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT); 413 ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
408} 414}
409 415
410#define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp)
411static inline int xfs_sb_version_addshared(xfs_sb_t *sbp)
412{
413 return (sbp)->sb_versionnum = \
414 ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT);
415}
416
417#define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp)
418static inline int xfs_sb_version_subshared(xfs_sb_t *sbp)
419{
420 return (sbp)->sb_versionnum = \
421 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT);
422}
423
424#define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp)
425static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) 416static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
426{ 417{
427 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 418 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
428 ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); 419 ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
429} 420}
430 421
431#define XFS_SB_VERSION_HASLOGV2(sbp) xfs_sb_version_haslogv2(sbp)
432static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) 422static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
433{ 423{
434 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 424 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
435 ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); 425 ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT);
436} 426}
437 427
438#define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp)
439static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) 428static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
440{ 429{
441 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 430 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
442 ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); 431 ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT);
443} 432}
444 433
445#define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp)
446static inline int xfs_sb_version_addextflgbit(xfs_sb_t *sbp)
447{
448 return (sbp)->sb_versionnum = \
449 ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT);
450}
451
452#define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp)
453static inline int xfs_sb_version_subextflgbit(xfs_sb_t *sbp)
454{
455 return (sbp)->sb_versionnum = \
456 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT);
457}
458
459#define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp)
460static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) 434static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
461{ 435{
462 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 436 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
463 ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT); 437 ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
464} 438}
465 439
466#define XFS_SB_VERSION_HASMOREBITS(sbp) xfs_sb_version_hasmorebits(sbp)
467static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) 440static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
468{ 441{
469 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \ 442 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
@@ -476,24 +449,22 @@ static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
476 * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro: 449 * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
477 * 450 *
478 * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp) 451 * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
479 * ((XFS_SB_VERSION_HASMOREBITS(sbp) && 452 * ((xfs_sb_version_hasmorebits(sbp) &&
480 * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT) 453 * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
481 */ 454 */
482 455
483static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) 456static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp)
484{ 457{
485 return (XFS_SB_VERSION_HASMOREBITS(sbp) && \ 458 return (xfs_sb_version_hasmorebits(sbp) && \
486 ((sbp)->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); 459 ((sbp)->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT));
487} 460}
488 461
489#define XFS_SB_VERSION_HASATTR2(sbp) xfs_sb_version_hasattr2(sbp)
490static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) 462static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
491{ 463{
492 return (XFS_SB_VERSION_HASMOREBITS(sbp)) && \ 464 return (xfs_sb_version_hasmorebits(sbp)) && \
493 ((sbp)->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); 465 ((sbp)->sb_features2 & XFS_SB_VERSION2_ATTR2BIT);
494} 466}
495 467
496#define XFS_SB_VERSION_ADDATTR2(sbp) xfs_sb_version_addattr2(sbp)
497static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) 468static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
498{ 469{
499 ((sbp)->sb_versionnum = \ 470 ((sbp)->sb_versionnum = \
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index 45d740df53b7..18a85e746680 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -339,10 +339,10 @@ xfs_bump_ino_vers2(
339 ip->i_d.di_onlink = 0; 339 ip->i_d.di_onlink = 0;
340 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); 340 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
341 mp = tp->t_mountp; 341 mp = tp->t_mountp;
342 if (!XFS_SB_VERSION_HASNLINK(&mp->m_sb)) { 342 if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
343 spin_lock(&mp->m_sb_lock); 343 spin_lock(&mp->m_sb_lock);
344 if (!XFS_SB_VERSION_HASNLINK(&mp->m_sb)) { 344 if (!xfs_sb_version_hasnlink(&mp->m_sb)) {
345 XFS_SB_VERSION_ADDNLINK(&mp->m_sb); 345 xfs_sb_version_addnlink(&mp->m_sb);
346 spin_unlock(&mp->m_sb_lock); 346 spin_unlock(&mp->m_sb_lock);
347 xfs_mod_sb(tp, XFS_SB_VERSIONNUM); 347 xfs_mod_sb(tp, XFS_SB_VERSIONNUM);
348 } else { 348 } else {
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index 7321304a69cc..7094caff13cf 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -330,7 +330,7 @@ xfs_finish_flags(
330 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY); 330 int ronly = (mp->m_flags & XFS_MOUNT_RDONLY);
331 331
332 /* Fail a mount where the logbuf is smaller then the log stripe */ 332 /* Fail a mount where the logbuf is smaller then the log stripe */
333 if (XFS_SB_VERSION_HASLOGV2(&mp->m_sb)) { 333 if (xfs_sb_version_haslogv2(&mp->m_sb)) {
334 if ((ap->logbufsize <= 0) && 334 if ((ap->logbufsize <= 0) &&
335 (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) { 335 (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) {
336 mp->m_logbsize = mp->m_sb.sb_logsunit; 336 mp->m_logbsize = mp->m_sb.sb_logsunit;
@@ -349,9 +349,8 @@ xfs_finish_flags(
349 } 349 }
350 } 350 }
351 351
352 if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) { 352 if (xfs_sb_version_hasattr2(&mp->m_sb))
353 mp->m_flags |= XFS_MOUNT_ATTR2; 353 mp->m_flags |= XFS_MOUNT_ATTR2;
354 }
355 354
356 /* 355 /*
357 * prohibit r/w mounts of read-only filesystems 356 * prohibit r/w mounts of read-only filesystems
@@ -366,7 +365,7 @@ xfs_finish_flags(
366 * check for shared mount. 365 * check for shared mount.
367 */ 366 */
368 if (ap->flags & XFSMNT_SHARED) { 367 if (ap->flags & XFSMNT_SHARED) {
369 if (!XFS_SB_VERSION_HASSHARED(&mp->m_sb)) 368 if (!xfs_sb_version_hasshared(&mp->m_sb))
370 return XFS_ERROR(EINVAL); 369 return XFS_ERROR(EINVAL);
371 370
372 /* 371 /*
@@ -512,7 +511,7 @@ xfs_mount(
512 if (!error && logdev && logdev != ddev) { 511 if (!error && logdev && logdev != ddev) {
513 unsigned int log_sector_size = BBSIZE; 512 unsigned int log_sector_size = BBSIZE;
514 513
515 if (XFS_SB_VERSION_HASSECTOR(&mp->m_sb)) 514 if (xfs_sb_version_hassector(&mp->m_sb))
516 log_sector_size = mp->m_sb.sb_logsectsize; 515 log_sector_size = mp->m_sb.sb_logsectsize;
517 error = xfs_setsize_buftarg(mp->m_logdev_targp, 516 error = xfs_setsize_buftarg(mp->m_logdev_targp,
518 mp->m_sb.sb_blocksize, 517 mp->m_sb.sb_blocksize,
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 51305242ff8c..64c5953feca4 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -4132,7 +4132,7 @@ xfs_free_file_space(
4132 * actually need to zero the extent edges. Otherwise xfs_bunmapi 4132 * actually need to zero the extent edges. Otherwise xfs_bunmapi
4133 * will take care of it for us. 4133 * will take care of it for us.
4134 */ 4134 */
4135 if (rt && !XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb)) { 4135 if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
4136 nimap = 1; 4136 nimap = 1;
4137 error = xfs_bmapi(NULL, ip, startoffset_fsb, 4137 error = xfs_bmapi(NULL, ip, startoffset_fsb,
4138 1, 0, NULL, 0, &imap, &nimap, NULL, NULL); 4138 1, 0, NULL, 0, &imap, &nimap, NULL, NULL);