aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorAlex Elder <aelder@sgi.com>2011-08-08 08:06:24 -0400
committerAlex Elder <aelder@sgi.com>2011-08-08 08:06:24 -0400
commit2ddb4e94065470828e131351566102274ea9e83f (patch)
tree3eb237d28e10d7735d57c051880e8173113acef8 /fs/xfs
parentc35a549c8b9e85bdff7e531a410d10e36b4b4f32 (diff)
parent322a8b034003c0d46d39af85bf24fee27b902f48 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_acl.c84
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c18
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c19
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c27
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c71
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.h5
-rw-r--r--fs/xfs/linux-2.6/xfs_trace.h2
-rw-r--r--fs/xfs/xfs_acl.h7
-rw-r--r--fs/xfs/xfs_bmap.c7
-rw-r--r--fs/xfs/xfs_da_btree.c32
-rw-r--r--fs/xfs/xfs_dir2.c16
-rw-r--r--fs/xfs/xfs_dir2_node.c2
-rw-r--r--fs/xfs/xfs_filestream.c14
-rw-r--r--fs/xfs/xfs_inode.c16
-rw-r--r--fs/xfs/xfs_inode.h2
-rw-r--r--fs/xfs/xfs_log_recover.c4
-rw-r--r--fs/xfs/xfs_mount.c2
-rw-r--r--fs/xfs/xfs_rename.c4
-rw-r--r--fs/xfs/xfs_vnodeops.c10
22 files changed, 165 insertions, 189 deletions
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c
index 115ac691953..b6c4b3795c4 100644
--- a/fs/xfs/linux-2.6/xfs_acl.c
+++ b/fs/xfs/linux-2.6/xfs_acl.c
@@ -114,6 +114,8 @@ xfs_get_acl(struct inode *inode, int type)
114 if (acl != ACL_NOT_CACHED) 114 if (acl != ACL_NOT_CACHED)
115 return acl; 115 return acl;
116 116
117 trace_xfs_get_acl(ip);
118
117 switch (type) { 119 switch (type) {
118 case ACL_TYPE_ACCESS: 120 case ACL_TYPE_ACCESS:
119 ea_name = SGI_ACL_FILE; 121 ea_name = SGI_ACL_FILE;
@@ -218,42 +220,8 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
218 return error; 220 return error;
219} 221}
220 222
221int
222xfs_check_acl(struct inode *inode, int mask, unsigned int flags)
223{
224 struct xfs_inode *ip;
225 struct posix_acl *acl;
226 int error = -EAGAIN;
227
228 ip = XFS_I(inode);
229 trace_xfs_check_acl(ip);
230
231 /*
232 * If there is no attribute fork no ACL exists on this inode and
233 * we can skip the whole exercise.
234 */
235 if (!XFS_IFORK_Q(ip))
236 return -EAGAIN;
237
238 if (flags & IPERM_FLAG_RCU) {
239 if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
240 return -ECHILD;
241 return -EAGAIN;
242 }
243
244 acl = xfs_get_acl(inode, ACL_TYPE_ACCESS);
245 if (IS_ERR(acl))
246 return PTR_ERR(acl);
247 if (acl) {
248 error = posix_acl_permission(inode, acl, mask);
249 posix_acl_release(acl);
250 }
251
252 return error;
253}
254
255static int 223static int
256xfs_set_mode(struct inode *inode, mode_t mode) 224xfs_set_mode(struct inode *inode, umode_t mode)
257{ 225{
258 int error = 0; 226 int error = 0;
259 227
@@ -297,29 +265,23 @@ posix_acl_default_exists(struct inode *inode)
297 * No need for i_mutex because the inode is not yet exposed to the VFS. 265 * No need for i_mutex because the inode is not yet exposed to the VFS.
298 */ 266 */
299int 267int
300xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl) 268xfs_inherit_acl(struct inode *inode, struct posix_acl *acl)
301{ 269{
302 struct posix_acl *clone; 270 umode_t mode = inode->i_mode;
303 mode_t mode;
304 int error = 0, inherit = 0; 271 int error = 0, inherit = 0;
305 272
306 if (S_ISDIR(inode->i_mode)) { 273 if (S_ISDIR(inode->i_mode)) {
307 error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl); 274 error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, acl);
308 if (error) 275 if (error)
309 return error; 276 goto out;
310 } 277 }
311 278
312 clone = posix_acl_clone(default_acl, GFP_KERNEL); 279 error = posix_acl_create(&acl, GFP_KERNEL, &mode);
313 if (!clone)
314 return -ENOMEM;
315
316 mode = inode->i_mode;
317 error = posix_acl_create_masq(clone, &mode);
318 if (error < 0) 280 if (error < 0)
319 goto out_release_clone; 281 return error;
320 282
321 /* 283 /*
322 * If posix_acl_create_masq returns a positive value we need to 284 * If posix_acl_create returns a positive value we need to
323 * inherit a permission that can't be represented using the Unix 285 * inherit a permission that can't be represented using the Unix
324 * mode bits and we actually need to set an ACL. 286 * mode bits and we actually need to set an ACL.
325 */ 287 */
@@ -328,20 +290,20 @@ xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl)
328 290
329 error = xfs_set_mode(inode, mode); 291 error = xfs_set_mode(inode, mode);
330 if (error) 292 if (error)
331 goto out_release_clone; 293 goto out;
332 294
333 if (inherit) 295 if (inherit)
334 error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone); 296 error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
335 297
336 out_release_clone: 298out:
337 posix_acl_release(clone); 299 posix_acl_release(acl);
338 return error; 300 return error;
339} 301}
340 302
341int 303int
342xfs_acl_chmod(struct inode *inode) 304xfs_acl_chmod(struct inode *inode)
343{ 305{
344 struct posix_acl *acl, *clone; 306 struct posix_acl *acl;
345 int error; 307 int error;
346 308
347 if (S_ISLNK(inode->i_mode)) 309 if (S_ISLNK(inode->i_mode))
@@ -351,16 +313,12 @@ xfs_acl_chmod(struct inode *inode)
351 if (IS_ERR(acl) || !acl) 313 if (IS_ERR(acl) || !acl)
352 return PTR_ERR(acl); 314 return PTR_ERR(acl);
353 315
354 clone = posix_acl_clone(acl, GFP_KERNEL); 316 error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
355 posix_acl_release(acl); 317 if (error)
356 if (!clone) 318 return error;
357 return -ENOMEM;
358
359 error = posix_acl_chmod_masq(clone, inode->i_mode);
360 if (!error)
361 error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
362 319
363 posix_acl_release(clone); 320 error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
321 posix_acl_release(acl);
364 return error; 322 return error;
365} 323}
366 324
@@ -423,7 +381,7 @@ xfs_xattr_acl_set(struct dentry *dentry, const char *name,
423 goto out_release; 381 goto out_release;
424 382
425 if (type == ACL_TYPE_ACCESS) { 383 if (type == ACL_TYPE_ACCESS) {
426 mode_t mode = inode->i_mode; 384 umode_t mode = inode->i_mode;
427 error = posix_acl_equiv_mode(acl, &mode); 385 error = posix_acl_equiv_mode(acl, &mode);
428 386
429 if (error <= 0) { 387 if (error <= 0) {
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 26384fe3f26..63e971e2b83 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1329,6 +1329,9 @@ xfs_end_io_direct_write(
1329 } else { 1329 } else {
1330 xfs_finish_ioend_sync(ioend); 1330 xfs_finish_ioend_sync(ioend);
1331 } 1331 }
1332
1333 /* XXX: probably should move into the real I/O completion handler */
1334 inode_dio_done(ioend->io_inode);
1332} 1335}
1333 1336
1334STATIC ssize_t 1337STATIC ssize_t
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 6bddce40de7..c57836dc778 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1223,6 +1223,9 @@ _xfs_buf_ioapply(
1223 rw = READ; 1223 rw = READ;
1224 } 1224 }
1225 1225
1226 /* we only use the buffer cache for meta-data */
1227 rw |= REQ_META;
1228
1226next_chunk: 1229next_chunk:
1227 atomic_inc(&bp->b_io_remaining); 1230 atomic_inc(&bp->b_io_remaining);
1228 nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT); 1231 nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT);
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 8073f61efb8..7f7b42469ea 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -127,6 +127,8 @@ xfs_iozero(
127STATIC int 127STATIC int
128xfs_file_fsync( 128xfs_file_fsync(
129 struct file *file, 129 struct file *file,
130 loff_t start,
131 loff_t end,
130 int datasync) 132 int datasync)
131{ 133{
132 struct inode *inode = file->f_mapping->host; 134 struct inode *inode = file->f_mapping->host;
@@ -138,12 +140,18 @@ xfs_file_fsync(
138 140
139 trace_xfs_file_fsync(ip); 141 trace_xfs_file_fsync(ip);
140 142
143 error = filemap_write_and_wait_range(inode->i_mapping, start, end);
144 if (error)
145 return error;
146
141 if (XFS_FORCED_SHUTDOWN(mp)) 147 if (XFS_FORCED_SHUTDOWN(mp))
142 return -XFS_ERROR(EIO); 148 return -XFS_ERROR(EIO);
143 149
144 xfs_iflags_clear(ip, XFS_ITRUNCATED); 150 xfs_iflags_clear(ip, XFS_ITRUNCATED);
145 151
152 xfs_ilock(ip, XFS_IOLOCK_SHARED);
146 xfs_ioend_wait(ip); 153 xfs_ioend_wait(ip);
154 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
147 155
148 if (mp->m_flags & XFS_MOUNT_BARRIER) { 156 if (mp->m_flags & XFS_MOUNT_BARRIER) {
149 /* 157 /*
@@ -875,18 +883,14 @@ xfs_file_aio_write(
875 /* Handle various SYNC-type writes */ 883 /* Handle various SYNC-type writes */
876 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) { 884 if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
877 loff_t end = pos + ret - 1; 885 loff_t end = pos + ret - 1;
878 int error, error2; 886 int error;
879 887
880 xfs_rw_iunlock(ip, iolock); 888 xfs_rw_iunlock(ip, iolock);
881 error = filemap_write_and_wait_range(mapping, pos, end); 889 error = xfs_file_fsync(file, pos, end,
890 (file->f_flags & __O_SYNC) ? 0 : 1);
882 xfs_rw_ilock(ip, iolock); 891 xfs_rw_ilock(ip, iolock);
883
884 error2 = -xfs_file_fsync(file,
885 (file->f_flags & __O_SYNC) ? 0 : 1);
886 if (error) 892 if (error)
887 ret = error; 893 ret = error;
888 else if (error2)
889 ret = error2;
890 } 894 }
891 895
892out_unlock: 896out_unlock:
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index acca2c5ca3f..f7ce7debe14 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -265,7 +265,7 @@ xfs_open_by_handle(
265 return PTR_ERR(filp); 265 return PTR_ERR(filp);
266 } 266 }
267 267
268 if (inode->i_mode & S_IFREG) { 268 if (S_ISREG(inode->i_mode)) {
269 filp->f_flags |= O_NOATIME; 269 filp->f_flags |= O_NOATIME;
270 filp->f_mode |= FMODE_NOCMTIME; 270 filp->f_mode |= FMODE_NOCMTIME;
271 } 271 }
@@ -850,14 +850,14 @@ xfs_set_diflags(
850 di_flags |= XFS_DIFLAG_NODEFRAG; 850 di_flags |= XFS_DIFLAG_NODEFRAG;
851 if (xflags & XFS_XFLAG_FILESTREAM) 851 if (xflags & XFS_XFLAG_FILESTREAM)
852 di_flags |= XFS_DIFLAG_FILESTREAM; 852 di_flags |= XFS_DIFLAG_FILESTREAM;
853 if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { 853 if (S_ISDIR(ip->i_d.di_mode)) {
854 if (xflags & XFS_XFLAG_RTINHERIT) 854 if (xflags & XFS_XFLAG_RTINHERIT)
855 di_flags |= XFS_DIFLAG_RTINHERIT; 855 di_flags |= XFS_DIFLAG_RTINHERIT;
856 if (xflags & XFS_XFLAG_NOSYMLINKS) 856 if (xflags & XFS_XFLAG_NOSYMLINKS)
857 di_flags |= XFS_DIFLAG_NOSYMLINKS; 857 di_flags |= XFS_DIFLAG_NOSYMLINKS;
858 if (xflags & XFS_XFLAG_EXTSZINHERIT) 858 if (xflags & XFS_XFLAG_EXTSZINHERIT)
859 di_flags |= XFS_DIFLAG_EXTSZINHERIT; 859 di_flags |= XFS_DIFLAG_EXTSZINHERIT;
860 } else if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) { 860 } else if (S_ISREG(ip->i_d.di_mode)) {
861 if (xflags & XFS_XFLAG_REALTIME) 861 if (xflags & XFS_XFLAG_REALTIME)
862 di_flags |= XFS_DIFLAG_REALTIME; 862 di_flags |= XFS_DIFLAG_REALTIME;
863 if (xflags & XFS_XFLAG_EXTSIZE) 863 if (xflags & XFS_XFLAG_EXTSIZE)
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 501e4f63054..b9c172b3fbb 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -202,9 +202,9 @@ xfs_vn_mknod(
202 202
203 if (default_acl) { 203 if (default_acl) {
204 error = -xfs_inherit_acl(inode, default_acl); 204 error = -xfs_inherit_acl(inode, default_acl);
205 default_acl = NULL;
205 if (unlikely(error)) 206 if (unlikely(error))
206 goto out_cleanup_inode; 207 goto out_cleanup_inode;
207 posix_acl_release(default_acl);
208 } 208 }
209 209
210 210
@@ -1022,7 +1022,7 @@ xfs_vn_fiemap(
1022} 1022}
1023 1023
1024static const struct inode_operations xfs_inode_operations = { 1024static const struct inode_operations xfs_inode_operations = {
1025 .check_acl = xfs_check_acl, 1025 .get_acl = xfs_get_acl,
1026 .getattr = xfs_vn_getattr, 1026 .getattr = xfs_vn_getattr,
1027 .setattr = xfs_vn_setattr, 1027 .setattr = xfs_vn_setattr,
1028 .setxattr = generic_setxattr, 1028 .setxattr = generic_setxattr,
@@ -1048,7 +1048,7 @@ static const struct inode_operations xfs_dir_inode_operations = {
1048 .rmdir = xfs_vn_unlink, 1048 .rmdir = xfs_vn_unlink,
1049 .mknod = xfs_vn_mknod, 1049 .mknod = xfs_vn_mknod,
1050 .rename = xfs_vn_rename, 1050 .rename = xfs_vn_rename,
1051 .check_acl = xfs_check_acl, 1051 .get_acl = xfs_get_acl,
1052 .getattr = xfs_vn_getattr, 1052 .getattr = xfs_vn_getattr,
1053 .setattr = xfs_vn_setattr, 1053 .setattr = xfs_vn_setattr,
1054 .setxattr = generic_setxattr, 1054 .setxattr = generic_setxattr,
@@ -1073,7 +1073,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = {
1073 .rmdir = xfs_vn_unlink, 1073 .rmdir = xfs_vn_unlink,
1074 .mknod = xfs_vn_mknod, 1074 .mknod = xfs_vn_mknod,
1075 .rename = xfs_vn_rename, 1075 .rename = xfs_vn_rename,
1076 .check_acl = xfs_check_acl, 1076 .get_acl = xfs_get_acl,
1077 .getattr = xfs_vn_getattr, 1077 .getattr = xfs_vn_getattr,
1078 .setattr = xfs_vn_setattr, 1078 .setattr = xfs_vn_setattr,
1079 .setxattr = generic_setxattr, 1079 .setxattr = generic_setxattr,
@@ -1086,7 +1086,7 @@ static const struct inode_operations xfs_symlink_inode_operations = {
1086 .readlink = generic_readlink, 1086 .readlink = generic_readlink,
1087 .follow_link = xfs_vn_follow_link, 1087 .follow_link = xfs_vn_follow_link,
1088 .put_link = xfs_vn_put_link, 1088 .put_link = xfs_vn_put_link,
1089 .check_acl = xfs_check_acl, 1089 .get_acl = xfs_get_acl,
1090 .getattr = xfs_vn_getattr, 1090 .getattr = xfs_vn_getattr,
1091 .setattr = xfs_vn_setattr, 1091 .setattr = xfs_vn_setattr,
1092 .setxattr = generic_setxattr, 1092 .setxattr = generic_setxattr,
@@ -1194,6 +1194,15 @@ xfs_setup_inode(
1194 break; 1194 break;
1195 } 1195 }
1196 1196
1197 /*
1198 * If there is no attribute fork no ACL can exist on this inode,
1199 * and it can't have any file capabilities attached to it either.
1200 */
1201 if (!XFS_IFORK_Q(ip)) {
1202 inode_has_no_xattr(inode);
1203 cache_no_acl(inode);
1204 }
1205
1197 xfs_iflags_clear(ip, XFS_INEW); 1206 xfs_iflags_clear(ip, XFS_INEW);
1198 barrier(); 1207 barrier();
1199 1208
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 25fd2cd6c8b..9a72dda58bd 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1024,11 +1024,6 @@ xfs_fs_put_super(
1024{ 1024{
1025 struct xfs_mount *mp = XFS_M(sb); 1025 struct xfs_mount *mp = XFS_M(sb);
1026 1026
1027 /*
1028 * Unregister the memory shrinker before we tear down the mount
1029 * structure so we don't have memory reclaim racing with us here.
1030 */
1031 xfs_inode_shrinker_unregister(mp);
1032 xfs_syncd_stop(mp); 1027 xfs_syncd_stop(mp);
1033 1028
1034 /* 1029 /*
@@ -1411,8 +1406,6 @@ xfs_fs_fill_super(
1411 sb->s_time_gran = 1; 1406 sb->s_time_gran = 1;
1412 set_posix_acl_flag(sb); 1407 set_posix_acl_flag(sb);
1413 1408
1414 xfs_inode_shrinker_register(mp);
1415
1416 error = xfs_mountfs(mp); 1409 error = xfs_mountfs(mp);
1417 if (error) 1410 if (error)
1418 goto out_filestream_unmount; 1411 goto out_filestream_unmount;
@@ -1439,7 +1432,6 @@ xfs_fs_fill_super(
1439 return 0; 1432 return 0;
1440 1433
1441 out_filestream_unmount: 1434 out_filestream_unmount:
1442 xfs_inode_shrinker_unregister(mp);
1443 xfs_filestream_unmount(mp); 1435 xfs_filestream_unmount(mp);
1444 out_free_sb: 1436 out_free_sb:
1445 xfs_freesb(mp); 1437 xfs_freesb(mp);
@@ -1458,8 +1450,6 @@ xfs_fs_fill_super(
1458 out_syncd_stop: 1450 out_syncd_stop:
1459 xfs_syncd_stop(mp); 1451 xfs_syncd_stop(mp);
1460 out_unmount: 1452 out_unmount:
1461 xfs_inode_shrinker_unregister(mp);
1462
1463 /* 1453 /*
1464 * Blow away any referenced inode in the filestreams cache. 1454 * Blow away any referenced inode in the filestreams cache.
1465 * This can and will cause log traffic as inodes go inactive 1455 * This can and will cause log traffic as inodes go inactive
@@ -1483,6 +1473,21 @@ xfs_fs_mount(
1483 return mount_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super); 1473 return mount_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
1484} 1474}
1485 1475
1476static int
1477xfs_fs_nr_cached_objects(
1478 struct super_block *sb)
1479{
1480 return xfs_reclaim_inodes_count(XFS_M(sb));
1481}
1482
1483static void
1484xfs_fs_free_cached_objects(
1485 struct super_block *sb,
1486 int nr_to_scan)
1487{
1488 xfs_reclaim_inodes_nr(XFS_M(sb), nr_to_scan);
1489}
1490
1486static const struct super_operations xfs_super_operations = { 1491static const struct super_operations xfs_super_operations = {
1487 .alloc_inode = xfs_fs_alloc_inode, 1492 .alloc_inode = xfs_fs_alloc_inode,
1488 .destroy_inode = xfs_fs_destroy_inode, 1493 .destroy_inode = xfs_fs_destroy_inode,
@@ -1496,6 +1501,8 @@ static const struct super_operations xfs_super_operations = {
1496 .statfs = xfs_fs_statfs, 1501 .statfs = xfs_fs_statfs,
1497 .remount_fs = xfs_fs_remount, 1502 .remount_fs = xfs_fs_remount,
1498 .show_options = xfs_fs_show_options, 1503 .show_options = xfs_fs_show_options,
1504 .nr_cached_objects = xfs_fs_nr_cached_objects,
1505 .free_cached_objects = xfs_fs_free_cached_objects,
1499}; 1506};
1500 1507
1501static struct file_system_type xfs_fs_type = { 1508static struct file_system_type xfs_fs_type = {
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index a8500e92ae7..4604f90f86a 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -179,6 +179,8 @@ restart:
179 if (error == EFSCORRUPTED) 179 if (error == EFSCORRUPTED)
180 break; 180 break;
181 181
182 cond_resched();
183
182 } while (nr_found && !done); 184 } while (nr_found && !done);
183 185
184 if (skipped) { 186 if (skipped) {
@@ -984,6 +986,8 @@ restart:
984 986
985 *nr_to_scan -= XFS_LOOKUP_BATCH; 987 *nr_to_scan -= XFS_LOOKUP_BATCH;
986 988
989 cond_resched();
990
987 } while (nr_found && !done && *nr_to_scan > 0); 991 } while (nr_found && !done && *nr_to_scan > 0);
988 992
989 if (trylock && !done) 993 if (trylock && !done)
@@ -1001,7 +1005,7 @@ restart:
1001 * ensure that when we get more reclaimers than AGs we block rather 1005 * ensure that when we get more reclaimers than AGs we block rather
1002 * than spin trying to execute reclaim. 1006 * than spin trying to execute reclaim.
1003 */ 1007 */
1004 if (trylock && skipped && *nr_to_scan > 0) { 1008 if (skipped && (flags & SYNC_WAIT) && *nr_to_scan > 0) {
1005 trylock = 0; 1009 trylock = 0;
1006 goto restart; 1010 goto restart;
1007 } 1011 }
@@ -1019,44 +1023,38 @@ xfs_reclaim_inodes(
1019} 1023}
1020 1024
1021/* 1025/*
1022 * Inode cache shrinker. 1026 * Scan a certain number of inodes for reclaim.
1023 * 1027 *
1024 * When called we make sure that there is a background (fast) inode reclaim in 1028 * When called we make sure that there is a background (fast) inode reclaim in
1025 * progress, while we will throttle the speed of reclaim via doiing synchronous 1029 * progress, while we will throttle the speed of reclaim via doing synchronous
1026 * reclaim of inodes. That means if we come across dirty inodes, we wait for 1030 * reclaim of inodes. That means if we come across dirty inodes, we wait for
1027 * them to be cleaned, which we hope will not be very long due to the 1031 * them to be cleaned, which we hope will not be very long due to the
1028 * background walker having already kicked the IO off on those dirty inodes. 1032 * background walker having already kicked the IO off on those dirty inodes.
1029 */ 1033 */
1030static int 1034void
1031xfs_reclaim_inode_shrink( 1035xfs_reclaim_inodes_nr(
1032 struct shrinker *shrink, 1036 struct xfs_mount *mp,
1033 struct shrink_control *sc) 1037 int nr_to_scan)
1034{ 1038{
1035 struct xfs_mount *mp; 1039 /* kick background reclaimer and push the AIL */
1036 struct xfs_perag *pag; 1040 xfs_syncd_queue_reclaim(mp);
1037 xfs_agnumber_t ag; 1041 xfs_ail_push_all(mp->m_ail);
1038 int reclaimable;
1039 int nr_to_scan = sc->nr_to_scan;
1040 gfp_t gfp_mask = sc->gfp_mask;
1041
1042 mp = container_of(shrink, struct xfs_mount, m_inode_shrink);
1043 if (nr_to_scan) {
1044 /* kick background reclaimer and push the AIL */
1045 xfs_syncd_queue_reclaim(mp);
1046 xfs_ail_push_all(mp->m_ail);
1047 1042
1048 if (!(gfp_mask & __GFP_FS)) 1043 xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, &nr_to_scan);
1049 return -1; 1044}
1050 1045
1051 xfs_reclaim_inodes_ag(mp, SYNC_TRYLOCK | SYNC_WAIT, 1046/*
1052 &nr_to_scan); 1047 * Return the number of reclaimable inodes in the filesystem for
1053 /* terminate if we don't exhaust the scan */ 1048 * the shrinker to determine how much to reclaim.
1054 if (nr_to_scan > 0) 1049 */
1055 return -1; 1050int
1056 } 1051xfs_reclaim_inodes_count(
1052 struct xfs_mount *mp)
1053{
1054 struct xfs_perag *pag;
1055 xfs_agnumber_t ag = 0;
1056 int reclaimable = 0;
1057 1057
1058 reclaimable = 0;
1059 ag = 0;
1060 while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) { 1058 while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) {
1061 ag = pag->pag_agno + 1; 1059 ag = pag->pag_agno + 1;
1062 reclaimable += pag->pag_ici_reclaimable; 1060 reclaimable += pag->pag_ici_reclaimable;
@@ -1065,18 +1063,3 @@ xfs_reclaim_inode_shrink(
1065 return reclaimable; 1063 return reclaimable;
1066} 1064}
1067 1065
1068void
1069xfs_inode_shrinker_register(
1070 struct xfs_mount *mp)
1071{
1072 mp->m_inode_shrink.shrink = xfs_reclaim_inode_shrink;
1073 mp->m_inode_shrink.seeks = DEFAULT_SEEKS;
1074 register_shrinker(&mp->m_inode_shrink);
1075}
1076
1077void
1078xfs_inode_shrinker_unregister(
1079 struct xfs_mount *mp)
1080{
1081 unregister_shrinker(&mp->m_inode_shrink);
1082}
diff --git a/fs/xfs/linux-2.6/xfs_sync.h b/fs/xfs/linux-2.6/xfs_sync.h
index e914fd62174..941202e7ac6 100644
--- a/fs/xfs/linux-2.6/xfs_sync.h
+++ b/fs/xfs/linux-2.6/xfs_sync.h
@@ -35,6 +35,8 @@ void xfs_quiesce_attr(struct xfs_mount *mp);
35void xfs_flush_inodes(struct xfs_inode *ip); 35void xfs_flush_inodes(struct xfs_inode *ip);
36 36
37int xfs_reclaim_inodes(struct xfs_mount *mp, int mode); 37int xfs_reclaim_inodes(struct xfs_mount *mp, int mode);
38int xfs_reclaim_inodes_count(struct xfs_mount *mp);
39void xfs_reclaim_inodes_nr(struct xfs_mount *mp, int nr_to_scan);
38 40
39void xfs_inode_set_reclaim_tag(struct xfs_inode *ip); 41void xfs_inode_set_reclaim_tag(struct xfs_inode *ip);
40void __xfs_inode_set_reclaim_tag(struct xfs_perag *pag, struct xfs_inode *ip); 42void __xfs_inode_set_reclaim_tag(struct xfs_perag *pag, struct xfs_inode *ip);
@@ -46,7 +48,4 @@ int xfs_inode_ag_iterator(struct xfs_mount *mp,
46 int (*execute)(struct xfs_inode *ip, struct xfs_perag *pag, int flags), 48 int (*execute)(struct xfs_inode *ip, struct xfs_perag *pag, int flags),
47 int flags); 49 int flags);
48 50
49void xfs_inode_shrinker_register(struct xfs_mount *mp);
50void xfs_inode_shrinker_unregister(struct xfs_mount *mp);
51
52#endif 51#endif
diff --git a/fs/xfs/linux-2.6/xfs_trace.h b/fs/xfs/linux-2.6/xfs_trace.h
index fda0708ef2e..690fc7a7bd7 100644
--- a/fs/xfs/linux-2.6/xfs_trace.h
+++ b/fs/xfs/linux-2.6/xfs_trace.h
@@ -571,7 +571,7 @@ DEFINE_INODE_EVENT(xfs_alloc_file_space);
571DEFINE_INODE_EVENT(xfs_free_file_space); 571DEFINE_INODE_EVENT(xfs_free_file_space);
572DEFINE_INODE_EVENT(xfs_readdir); 572DEFINE_INODE_EVENT(xfs_readdir);
573#ifdef CONFIG_XFS_POSIX_ACL 573#ifdef CONFIG_XFS_POSIX_ACL
574DEFINE_INODE_EVENT(xfs_check_acl); 574DEFINE_INODE_EVENT(xfs_get_acl);
575#endif 575#endif
576DEFINE_INODE_EVENT(xfs_vm_bmap); 576DEFINE_INODE_EVENT(xfs_vm_bmap);
577DEFINE_INODE_EVENT(xfs_file_ioctl); 577DEFINE_INODE_EVENT(xfs_file_ioctl);
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
index 11dd72070cb..39632d94135 100644
--- a/fs/xfs/xfs_acl.h
+++ b/fs/xfs/xfs_acl.h
@@ -42,7 +42,6 @@ struct xfs_acl {
42#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) 42#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
43 43
44#ifdef CONFIG_XFS_POSIX_ACL 44#ifdef CONFIG_XFS_POSIX_ACL
45extern int xfs_check_acl(struct inode *inode, int mask, unsigned int flags);
46extern struct posix_acl *xfs_get_acl(struct inode *inode, int type); 45extern struct posix_acl *xfs_get_acl(struct inode *inode, int type);
47extern int xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl); 46extern int xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl);
48extern int xfs_acl_chmod(struct inode *inode); 47extern int xfs_acl_chmod(struct inode *inode);
@@ -52,8 +51,10 @@ extern int posix_acl_default_exists(struct inode *inode);
52extern const struct xattr_handler xfs_xattr_acl_access_handler; 51extern const struct xattr_handler xfs_xattr_acl_access_handler;
53extern const struct xattr_handler xfs_xattr_acl_default_handler; 52extern const struct xattr_handler xfs_xattr_acl_default_handler;
54#else 53#else
55# define xfs_check_acl NULL 54static inline struct posix_acl *xfs_get_acl(struct inode *inode, int type)
56# define xfs_get_acl(inode, type) NULL 55{
56 return NULL;
57}
57# define xfs_inherit_acl(inode, default_acl) 0 58# define xfs_inherit_acl(inode, default_acl) 0
58# define xfs_acl_chmod(inode) 0 59# define xfs_acl_chmod(inode) 0
59# define posix_acl_access_exists(inode) 0 60# define posix_acl_access_exists(inode) 0
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 25cb2b2c427..452a291383a 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -414,7 +414,7 @@ xfs_bmap_add_attrfork_local(
414 414
415 if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip)) 415 if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
416 return 0; 416 return 0;
417 if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { 417 if (S_ISDIR(ip->i_d.di_mode)) {
418 mp = ip->i_mount; 418 mp = ip->i_mount;
419 memset(&dargs, 0, sizeof(dargs)); 419 memset(&dargs, 0, sizeof(dargs));
420 dargs.dp = ip; 420 dargs.dp = ip;
@@ -3344,8 +3344,7 @@ xfs_bmap_local_to_extents(
3344 * We don't want to deal with the case of keeping inode data inline yet. 3344 * We don't want to deal with the case of keeping inode data inline yet.
3345 * So sending the data fork of a regular inode is invalid. 3345 * So sending the data fork of a regular inode is invalid.
3346 */ 3346 */
3347 ASSERT(!((ip->i_d.di_mode & S_IFMT) == S_IFREG && 3347 ASSERT(!(S_ISREG(ip->i_d.di_mode) && whichfork == XFS_DATA_FORK));
3348 whichfork == XFS_DATA_FORK));
3349 ifp = XFS_IFORK_PTR(ip, whichfork); 3348 ifp = XFS_IFORK_PTR(ip, whichfork);
3350 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL); 3349 ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_LOCAL);
3351 flags = 0; 3350 flags = 0;
@@ -4051,7 +4050,7 @@ xfs_bmap_one_block(
4051 4050
4052#ifndef DEBUG 4051#ifndef DEBUG
4053 if (whichfork == XFS_DATA_FORK) { 4052 if (whichfork == XFS_DATA_FORK) {
4054 return ((ip->i_d.di_mode & S_IFMT) == S_IFREG) ? 4053 return S_ISREG(ip->i_d.di_mode) ?
4055 (ip->i_size == ip->i_mount->m_sb.sb_blocksize) : 4054 (ip->i_size == ip->i_mount->m_sb.sb_blocksize) :
4056 (ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize); 4055 (ip->i_d.di_size == ip->i_mount->m_sb.sb_blocksize);
4057 } 4056 }
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index d56ccb70965..ee9d5427fcd 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -692,6 +692,24 @@ xfs_da_join(xfs_da_state_t *state)
692 return(error); 692 return(error);
693} 693}
694 694
695#ifdef DEBUG
696static void
697xfs_da_blkinfo_onlychild_validate(struct xfs_da_blkinfo *blkinfo, __u16 level)
698{
699 __be16 magic = blkinfo->magic;
700
701 if (level == 1) {
702 ASSERT(magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
703 magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
704 } else
705 ASSERT(magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
706 ASSERT(!blkinfo->forw);
707 ASSERT(!blkinfo->back);
708}
709#else /* !DEBUG */
710#define xfs_da_blkinfo_onlychild_validate(blkinfo, level)
711#endif /* !DEBUG */
712
695/* 713/*
696 * We have only one entry in the root. Copy the only remaining child of 714 * We have only one entry in the root. Copy the only remaining child of
697 * the old root to block 0 as the new root node. 715 * the old root to block 0 as the new root node.
@@ -700,8 +718,6 @@ STATIC int
700xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) 718xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
701{ 719{
702 xfs_da_intnode_t *oldroot; 720 xfs_da_intnode_t *oldroot;
703 /* REFERENCED */
704 xfs_da_blkinfo_t *blkinfo;
705 xfs_da_args_t *args; 721 xfs_da_args_t *args;
706 xfs_dablk_t child; 722 xfs_dablk_t child;
707 xfs_dabuf_t *bp; 723 xfs_dabuf_t *bp;
@@ -732,15 +748,9 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
732 if (error) 748 if (error)
733 return(error); 749 return(error);
734 ASSERT(bp != NULL); 750 ASSERT(bp != NULL);
735 blkinfo = bp->data; 751 xfs_da_blkinfo_onlychild_validate(bp->data,
736 if (be16_to_cpu(oldroot->hdr.level) == 1) { 752 be16_to_cpu(oldroot->hdr.level));
737 ASSERT(blkinfo->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 753
738 blkinfo->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
739 } else {
740 ASSERT(blkinfo->magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
741 }
742 ASSERT(!blkinfo->forw);
743 ASSERT(!blkinfo->back);
744 memcpy(root_blk->bp->data, bp->data, state->blocksize); 754 memcpy(root_blk->bp->data, bp->data, state->blocksize);
745 xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); 755 xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1);
746 error = xfs_da_shrink_inode(args, child, bp); 756 error = xfs_da_shrink_inode(args, child, bp);
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 4580ce00aeb..a2e27010c7f 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -121,7 +121,7 @@ xfs_dir_isempty(
121{ 121{
122 xfs_dir2_sf_hdr_t *sfp; 122 xfs_dir2_sf_hdr_t *sfp;
123 123
124 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 124 ASSERT(S_ISDIR(dp->i_d.di_mode));
125 if (dp->i_d.di_size == 0) /* might happen during shutdown. */ 125 if (dp->i_d.di_size == 0) /* might happen during shutdown. */
126 return 1; 126 return 1;
127 if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp)) 127 if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
@@ -179,7 +179,7 @@ xfs_dir_init(
179 memset((char *)&args, 0, sizeof(args)); 179 memset((char *)&args, 0, sizeof(args));
180 args.dp = dp; 180 args.dp = dp;
181 args.trans = tp; 181 args.trans = tp;
182 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 182 ASSERT(S_ISDIR(dp->i_d.di_mode));
183 if ((error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino))) 183 if ((error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino)))
184 return error; 184 return error;
185 return xfs_dir2_sf_create(&args, pdp->i_ino); 185 return xfs_dir2_sf_create(&args, pdp->i_ino);
@@ -202,7 +202,7 @@ xfs_dir_createname(
202 int rval; 202 int rval;
203 int v; /* type-checking value */ 203 int v; /* type-checking value */
204 204
205 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 205 ASSERT(S_ISDIR(dp->i_d.di_mode));
206 if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum))) 206 if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum)))
207 return rval; 207 return rval;
208 XFS_STATS_INC(xs_dir_create); 208 XFS_STATS_INC(xs_dir_create);
@@ -278,7 +278,7 @@ xfs_dir_lookup(
278 int rval; 278 int rval;
279 int v; /* type-checking value */ 279 int v; /* type-checking value */
280 280
281 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 281 ASSERT(S_ISDIR(dp->i_d.di_mode));
282 XFS_STATS_INC(xs_dir_lookup); 282 XFS_STATS_INC(xs_dir_lookup);
283 283
284 memset(&args, 0, sizeof(xfs_da_args_t)); 284 memset(&args, 0, sizeof(xfs_da_args_t));
@@ -333,7 +333,7 @@ xfs_dir_removename(
333 int rval; 333 int rval;
334 int v; /* type-checking value */ 334 int v; /* type-checking value */
335 335
336 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 336 ASSERT(S_ISDIR(dp->i_d.di_mode));
337 XFS_STATS_INC(xs_dir_remove); 337 XFS_STATS_INC(xs_dir_remove);
338 338
339 memset(&args, 0, sizeof(xfs_da_args_t)); 339 memset(&args, 0, sizeof(xfs_da_args_t));
@@ -382,7 +382,7 @@ xfs_readdir(
382 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) 382 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
383 return XFS_ERROR(EIO); 383 return XFS_ERROR(EIO);
384 384
385 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 385 ASSERT(S_ISDIR(dp->i_d.di_mode));
386 XFS_STATS_INC(xs_dir_getdents); 386 XFS_STATS_INC(xs_dir_getdents);
387 387
388 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 388 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
@@ -414,7 +414,7 @@ xfs_dir_replace(
414 int rval; 414 int rval;
415 int v; /* type-checking value */ 415 int v; /* type-checking value */
416 416
417 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 417 ASSERT(S_ISDIR(dp->i_d.di_mode));
418 418
419 if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum))) 419 if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum)))
420 return rval; 420 return rval;
@@ -464,7 +464,7 @@ xfs_dir_canenter(
464 if (resblks) 464 if (resblks)
465 return 0; 465 return 0;
466 466
467 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 467 ASSERT(S_ISDIR(dp->i_d.di_mode));
468 468
469 memset(&args, 0, sizeof(xfs_da_args_t)); 469 memset(&args, 0, sizeof(xfs_da_args_t));
470 args.name = name->name; 470 args.name = name->name;
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 084b3247d63..0179a41d9e5 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -1564,7 +1564,7 @@ xfs_dir2_node_addname_int(
1564 1564
1565 if (unlikely(xfs_dir2_db_to_fdb(mp, dbno) != fbno)) { 1565 if (unlikely(xfs_dir2_db_to_fdb(mp, dbno) != fbno)) {
1566 xfs_alert(mp, 1566 xfs_alert(mp,
1567 "%s: dir ino " "%llu needed freesp block %lld for\n" 1567 "%s: dir ino %llu needed freesp block %lld for\n"
1568 " data block %lld, got %lld ifbno %llu lastfbno %d", 1568 " data block %lld, got %lld ifbno %llu lastfbno %d",
1569 __func__, (unsigned long long)dp->i_ino, 1569 __func__, (unsigned long long)dp->i_ino,
1570 (long long)xfs_dir2_db_to_fdb(mp, dbno), 1570 (long long)xfs_dir2_db_to_fdb(mp, dbno),
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
index 9124425b7f2..3ff3d9e23de 100644
--- a/fs/xfs/xfs_filestream.c
+++ b/fs/xfs/xfs_filestream.c
@@ -344,9 +344,9 @@ _xfs_filestream_update_ag(
344 * Either ip is a regular file and pip is a directory, or ip is a 344 * Either ip is a regular file and pip is a directory, or ip is a
345 * directory and pip is NULL. 345 * directory and pip is NULL.
346 */ 346 */
347 ASSERT(ip && (((ip->i_d.di_mode & S_IFREG) && pip && 347 ASSERT(ip && ((S_ISREG(ip->i_d.di_mode) && pip &&
348 (pip->i_d.di_mode & S_IFDIR)) || 348 S_ISDIR(pip->i_d.di_mode)) ||
349 ((ip->i_d.di_mode & S_IFDIR) && !pip))); 349 (S_ISDIR(ip->i_d.di_mode) && !pip)));
350 350
351 mp = ip->i_mount; 351 mp = ip->i_mount;
352 cache = mp->m_filestream; 352 cache = mp->m_filestream;
@@ -537,7 +537,7 @@ xfs_filestream_lookup_ag(
537 xfs_agnumber_t ag; 537 xfs_agnumber_t ag;
538 int ref; 538 int ref;
539 539
540 if (!(ip->i_d.di_mode & (S_IFREG | S_IFDIR))) { 540 if (!S_ISREG(ip->i_d.di_mode) && !S_ISDIR(ip->i_d.di_mode)) {
541 ASSERT(0); 541 ASSERT(0);
542 return NULLAGNUMBER; 542 return NULLAGNUMBER;
543 } 543 }
@@ -579,9 +579,9 @@ xfs_filestream_associate(
579 xfs_agnumber_t ag, rotorstep, startag; 579 xfs_agnumber_t ag, rotorstep, startag;
580 int err = 0; 580 int err = 0;
581 581
582 ASSERT(pip->i_d.di_mode & S_IFDIR); 582 ASSERT(S_ISDIR(pip->i_d.di_mode));
583 ASSERT(ip->i_d.di_mode & S_IFREG); 583 ASSERT(S_ISREG(ip->i_d.di_mode));
584 if (!(pip->i_d.di_mode & S_IFDIR) || !(ip->i_d.di_mode & S_IFREG)) 584 if (!S_ISDIR(pip->i_d.di_mode) || !S_ISREG(ip->i_d.di_mode))
585 return -EINVAL; 585 return -EINVAL;
586 586
587 mp = pip->i_mount; 587 mp = pip->i_mount;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 76ee2c5371c..0239a7c7c88 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -368,7 +368,7 @@ xfs_iformat(
368 /* 368 /*
369 * no local regular files yet 369 * no local regular files yet
370 */ 370 */
371 if (unlikely((be16_to_cpu(dip->di_mode) & S_IFMT) == S_IFREG)) { 371 if (unlikely(S_ISREG(be16_to_cpu(dip->di_mode)))) {
372 xfs_warn(ip->i_mount, 372 xfs_warn(ip->i_mount,
373 "corrupt inode %Lu (local format for regular file).", 373 "corrupt inode %Lu (local format for regular file).",
374 (unsigned long long) ip->i_ino); 374 (unsigned long long) ip->i_ino);
@@ -1040,7 +1040,7 @@ xfs_ialloc(
1040 1040
1041 if (pip && XFS_INHERIT_GID(pip)) { 1041 if (pip && XFS_INHERIT_GID(pip)) {
1042 ip->i_d.di_gid = pip->i_d.di_gid; 1042 ip->i_d.di_gid = pip->i_d.di_gid;
1043 if ((pip->i_d.di_mode & S_ISGID) && (mode & S_IFMT) == S_IFDIR) { 1043 if ((pip->i_d.di_mode & S_ISGID) && S_ISDIR(mode)) {
1044 ip->i_d.di_mode |= S_ISGID; 1044 ip->i_d.di_mode |= S_ISGID;
1045 } 1045 }
1046 } 1046 }
@@ -1097,14 +1097,14 @@ xfs_ialloc(
1097 if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) { 1097 if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
1098 uint di_flags = 0; 1098 uint di_flags = 0;
1099 1099
1100 if ((mode & S_IFMT) == S_IFDIR) { 1100 if (S_ISDIR(mode)) {
1101 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) 1101 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
1102 di_flags |= XFS_DIFLAG_RTINHERIT; 1102 di_flags |= XFS_DIFLAG_RTINHERIT;
1103 if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) { 1103 if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
1104 di_flags |= XFS_DIFLAG_EXTSZINHERIT; 1104 di_flags |= XFS_DIFLAG_EXTSZINHERIT;
1105 ip->i_d.di_extsize = pip->i_d.di_extsize; 1105 ip->i_d.di_extsize = pip->i_d.di_extsize;
1106 } 1106 }
1107 } else if ((mode & S_IFMT) == S_IFREG) { 1107 } else if (S_ISREG(mode)) {
1108 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) 1108 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
1109 di_flags |= XFS_DIFLAG_REALTIME; 1109 di_flags |= XFS_DIFLAG_REALTIME;
1110 if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) { 1110 if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
@@ -1188,7 +1188,7 @@ xfs_isize_check(
1188 int nimaps; 1188 int nimaps;
1189 xfs_bmbt_irec_t imaps[2]; 1189 xfs_bmbt_irec_t imaps[2];
1190 1190
1191 if ((ip->i_d.di_mode & S_IFMT) != S_IFREG) 1191 if (!S_ISREG(ip->i_d.di_mode))
1192 return; 1192 return;
1193 1193
1194 if (XFS_IS_REALTIME_INODE(ip)) 1194 if (XFS_IS_REALTIME_INODE(ip))
@@ -1828,7 +1828,7 @@ xfs_ifree(
1828 ASSERT(ip->i_d.di_nextents == 0); 1828 ASSERT(ip->i_d.di_nextents == 0);
1829 ASSERT(ip->i_d.di_anextents == 0); 1829 ASSERT(ip->i_d.di_anextents == 0);
1830 ASSERT((ip->i_d.di_size == 0 && ip->i_size == 0) || 1830 ASSERT((ip->i_d.di_size == 0 && ip->i_size == 0) ||
1831 ((ip->i_d.di_mode & S_IFMT) != S_IFREG)); 1831 (!S_ISREG(ip->i_d.di_mode)));
1832 ASSERT(ip->i_d.di_nblocks == 0); 1832 ASSERT(ip->i_d.di_nblocks == 0);
1833 1833
1834 /* 1834 /*
@@ -2671,7 +2671,7 @@ xfs_iflush_int(
2671 __func__, ip->i_ino, ip, ip->i_d.di_magic); 2671 __func__, ip->i_ino, ip, ip->i_d.di_magic);
2672 goto corrupt_out; 2672 goto corrupt_out;
2673 } 2673 }
2674 if ((ip->i_d.di_mode & S_IFMT) == S_IFREG) { 2674 if (S_ISREG(ip->i_d.di_mode)) {
2675 if (XFS_TEST_ERROR( 2675 if (XFS_TEST_ERROR(
2676 (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) && 2676 (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) &&
2677 (ip->i_d.di_format != XFS_DINODE_FMT_BTREE), 2677 (ip->i_d.di_format != XFS_DINODE_FMT_BTREE),
@@ -2681,7 +2681,7 @@ xfs_iflush_int(
2681 __func__, ip->i_ino, ip); 2681 __func__, ip->i_ino, ip);
2682 goto corrupt_out; 2682 goto corrupt_out;
2683 } 2683 }
2684 } else if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { 2684 } else if (S_ISDIR(ip->i_d.di_mode)) {
2685 if (XFS_TEST_ERROR( 2685 if (XFS_TEST_ERROR(
2686 (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) && 2686 (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) &&
2687 (ip->i_d.di_format != XFS_DINODE_FMT_BTREE) && 2687 (ip->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index a97644ab945..2380a4bcbec 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -263,7 +263,7 @@ typedef struct xfs_inode {
263 struct inode i_vnode; /* embedded VFS inode */ 263 struct inode i_vnode; /* embedded VFS inode */
264} xfs_inode_t; 264} xfs_inode_t;
265 265
266#define XFS_ISIZE(ip) (((ip)->i_d.di_mode & S_IFMT) == S_IFREG) ? \ 266#define XFS_ISIZE(ip) S_ISREG((ip)->i_d.di_mode) ? \
267 (ip)->i_size : (ip)->i_d.di_size; 267 (ip)->i_size : (ip)->i_d.di_size;
268 268
269/* Convert from vfs inode to xfs inode */ 269/* Convert from vfs inode to xfs inode */
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 93786e518d8..1076b7effcd 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2277,7 +2277,7 @@ xlog_recover_inode_pass2(
2277 /* Take the opportunity to reset the flush iteration count */ 2277 /* Take the opportunity to reset the flush iteration count */
2278 dicp->di_flushiter = 0; 2278 dicp->di_flushiter = 0;
2279 2279
2280 if (unlikely((dicp->di_mode & S_IFMT) == S_IFREG)) { 2280 if (unlikely(S_ISREG(dicp->di_mode))) {
2281 if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) && 2281 if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) &&
2282 (dicp->di_format != XFS_DINODE_FMT_BTREE)) { 2282 (dicp->di_format != XFS_DINODE_FMT_BTREE)) {
2283 XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)", 2283 XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)",
@@ -2290,7 +2290,7 @@ xlog_recover_inode_pass2(
2290 error = EFSCORRUPTED; 2290 error = EFSCORRUPTED;
2291 goto error; 2291 goto error;
2292 } 2292 }
2293 } else if (unlikely((dicp->di_mode & S_IFMT) == S_IFDIR)) { 2293 } else if (unlikely(S_ISDIR(dicp->di_mode))) {
2294 if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) && 2294 if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) &&
2295 (dicp->di_format != XFS_DINODE_FMT_BTREE) && 2295 (dicp->di_format != XFS_DINODE_FMT_BTREE) &&
2296 (dicp->di_format != XFS_DINODE_FMT_LOCAL)) { 2296 (dicp->di_format != XFS_DINODE_FMT_LOCAL)) {
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 49ecc170f74..0081657ad98 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1331,7 +1331,7 @@ xfs_mountfs(
1331 1331
1332 ASSERT(rip != NULL); 1332 ASSERT(rip != NULL);
1333 1333
1334 if (unlikely((rip->i_d.di_mode & S_IFMT) != S_IFDIR)) { 1334 if (unlikely(!S_ISDIR(rip->i_d.di_mode))) {
1335 xfs_warn(mp, "corrupted root inode %llu: not a directory", 1335 xfs_warn(mp, "corrupted root inode %llu: not a directory",
1336 (unsigned long long)rip->i_ino); 1336 (unsigned long long)rip->i_ino);
1337 xfs_iunlock(rip, XFS_ILOCK_EXCL); 1337 xfs_iunlock(rip, XFS_ILOCK_EXCL);
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index 77a59891734..df78c297d1a 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -116,7 +116,7 @@ xfs_rename(
116 trace_xfs_rename(src_dp, target_dp, src_name, target_name); 116 trace_xfs_rename(src_dp, target_dp, src_name, target_name);
117 117
118 new_parent = (src_dp != target_dp); 118 new_parent = (src_dp != target_dp);
119 src_is_directory = ((src_ip->i_d.di_mode & S_IFMT) == S_IFDIR); 119 src_is_directory = S_ISDIR(src_ip->i_d.di_mode);
120 120
121 if (src_is_directory) { 121 if (src_is_directory) {
122 /* 122 /*
@@ -226,7 +226,7 @@ xfs_rename(
226 * target and source are directories and that target can be 226 * target and source are directories and that target can be
227 * destroyed, or that neither is a directory. 227 * destroyed, or that neither is a directory.
228 */ 228 */
229 if ((target_ip->i_d.di_mode & S_IFMT) == S_IFDIR) { 229 if (S_ISDIR(target_ip->i_d.di_mode)) {
230 /* 230 /*
231 * Make sure target dir is empty. 231 * Make sure target dir is empty.
232 */ 232 */
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 3ee5f8a2858..dd05360ad56 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -121,7 +121,7 @@ xfs_readlink(
121 121
122 xfs_ilock(ip, XFS_ILOCK_SHARED); 122 xfs_ilock(ip, XFS_ILOCK_SHARED);
123 123
124 ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFLNK); 124 ASSERT(S_ISLNK(ip->i_d.di_mode));
125 ASSERT(ip->i_d.di_size <= MAXPATHLEN); 125 ASSERT(ip->i_d.di_size <= MAXPATHLEN);
126 126
127 pathlen = ip->i_d.di_size; 127 pathlen = ip->i_d.di_size;
@@ -529,7 +529,7 @@ xfs_release(
529 if (ip->i_d.di_nlink == 0) 529 if (ip->i_d.di_nlink == 0)
530 return 0; 530 return 0;
531 531
532 if ((((ip->i_d.di_mode & S_IFMT) == S_IFREG) && 532 if ((S_ISREG(ip->i_d.di_mode) &&
533 ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 || 533 ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 ||
534 ip->i_delayed_blks > 0)) && 534 ip->i_delayed_blks > 0)) &&
535 (ip->i_df.if_flags & XFS_IFEXTENTS)) && 535 (ip->i_df.if_flags & XFS_IFEXTENTS)) &&
@@ -610,7 +610,7 @@ xfs_inactive(
610 truncate = ((ip->i_d.di_nlink == 0) && 610 truncate = ((ip->i_d.di_nlink == 0) &&
611 ((ip->i_d.di_size != 0) || (ip->i_size != 0) || 611 ((ip->i_d.di_size != 0) || (ip->i_size != 0) ||
612 (ip->i_d.di_nextents > 0) || (ip->i_delayed_blks > 0)) && 612 (ip->i_d.di_nextents > 0) || (ip->i_delayed_blks > 0)) &&
613 ((ip->i_d.di_mode & S_IFMT) == S_IFREG)); 613 S_ISREG(ip->i_d.di_mode));
614 614
615 mp = ip->i_mount; 615 mp = ip->i_mount;
616 616
@@ -621,7 +621,7 @@ xfs_inactive(
621 goto out; 621 goto out;
622 622
623 if (ip->i_d.di_nlink != 0) { 623 if (ip->i_d.di_nlink != 0) {
624 if ((((ip->i_d.di_mode & S_IFMT) == S_IFREG) && 624 if ((S_ISREG(ip->i_d.di_mode) &&
625 ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 || 625 ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 ||
626 ip->i_delayed_blks > 0)) && 626 ip->i_delayed_blks > 0)) &&
627 (ip->i_df.if_flags & XFS_IFEXTENTS) && 627 (ip->i_df.if_flags & XFS_IFEXTENTS) &&
@@ -669,7 +669,7 @@ xfs_inactive(
669 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 669 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
670 return VN_INACTIVE_CACHE; 670 return VN_INACTIVE_CACHE;
671 } 671 }
672 } else if ((ip->i_d.di_mode & S_IFMT) == S_IFLNK) { 672 } else if (S_ISLNK(ip->i_d.di_mode)) {
673 673
674 /* 674 /*
675 * If we get an error while cleaning up a 675 * If we get an error while cleaning up a