aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 11:39:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-18 11:39:39 -0400
commit253ba4e79edc695b2925bd2ef34de06ff4d4070c (patch)
tree259667140ca702d6a218cc54f4df275fbbda747b /fs/xfs/linux-2.6
parent188da98800893691e47eea9335a234378e32aceb (diff)
parent65e67f5165c8a156b34ee7adf65d5ed3b16a910d (diff)
Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6
* 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6: (87 commits) [XFS] Fix merge failure [XFS] The forward declarations for the xfs_ioctl() helpers and the [XFS] Update XFS documentation for noikeep/ikeep. [XFS] Update XFS Documentation for ikeep and ihashsize [XFS] Remove unused HAVE_SPLICE macro. [XFS] Remove CONFIG_XFS_SECURITY. [XFS] xfs_bmap_compute_maxlevels should be based on di_forkoff [XFS] Always use di_forkoff when checking for attr space. [XFS] Ensure the inode is joined in xfs_itruncate_finish [XFS] Remove periodic logging of in-core superblock counters. [XFS] fix logic error in xfs_alloc_ag_vextent_near() [XFS] Don't error out on good I/Os. [XFS] Catch log unmount failures. [XFS] Sanitise xfs_log_force error checking. [XFS] Check for errors when changing buffer pointers. [XFS] Don't allow silent errors in xfs_inactive(). [XFS] Catch errors from xfs_imap(). [XFS] xfs_bulkstat_one_dinode() never returns an error. [XFS] xfs_iflush_fork() never returns an error. [XFS] Catch unwritten extent conversion errors. ...
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r--fs/xfs/linux-2.6/kmem.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c12
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c8
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h8
-rw-r--r--fs/xfs/linux-2.6/xfs_cred.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c14
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c13
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.c36
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c676
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c223
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h1
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c70
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.h3
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c27
-rw-r--r--fs/xfs/linux-2.6/xfs_super.h8
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h1
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h30
18 files changed, 529 insertions, 613 deletions
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index e040f1ce1b6a..9b1bb17a0501 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -37,7 +37,7 @@ kmem_alloc(size_t size, unsigned int __nocast flags)
37#ifdef DEBUG 37#ifdef DEBUG
38 if (unlikely(!(flags & KM_LARGE) && (size > PAGE_SIZE))) { 38 if (unlikely(!(flags & KM_LARGE) && (size > PAGE_SIZE))) {
39 printk(KERN_WARNING "Large %s attempt, size=%ld\n", 39 printk(KERN_WARNING "Large %s attempt, size=%ld\n",
40 __FUNCTION__, (long)size); 40 __func__, (long)size);
41 dump_stack(); 41 dump_stack();
42 } 42 }
43#endif 43#endif
@@ -52,7 +52,7 @@ kmem_alloc(size_t size, unsigned int __nocast flags)
52 if (!(++retries % 100)) 52 if (!(++retries % 100))
53 printk(KERN_ERR "XFS: possible memory allocation " 53 printk(KERN_ERR "XFS: possible memory allocation "
54 "deadlock in %s (mode:0x%x)\n", 54 "deadlock in %s (mode:0x%x)\n",
55 __FUNCTION__, lflags); 55 __func__, lflags);
56 congestion_wait(WRITE, HZ/50); 56 congestion_wait(WRITE, HZ/50);
57 } while (1); 57 } while (1);
58} 58}
@@ -129,7 +129,7 @@ kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags)
129 if (!(++retries % 100)) 129 if (!(++retries % 100))
130 printk(KERN_ERR "XFS: possible memory allocation " 130 printk(KERN_ERR "XFS: possible memory allocation "
131 "deadlock in %s (mode:0x%x)\n", 131 "deadlock in %s (mode:0x%x)\n",
132 __FUNCTION__, lflags); 132 __func__, lflags);
133 congestion_wait(WRITE, HZ/50); 133 congestion_wait(WRITE, HZ/50);
134 } while (1); 134 } while (1);
135} 135}
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index e0519529c26c..a55c3b26d840 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -243,8 +243,12 @@ xfs_end_bio_unwritten(
243 size_t size = ioend->io_size; 243 size_t size = ioend->io_size;
244 244
245 if (likely(!ioend->io_error)) { 245 if (likely(!ioend->io_error)) {
246 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) 246 if (!XFS_FORCED_SHUTDOWN(ip->i_mount)) {
247 xfs_iomap_write_unwritten(ip, offset, size); 247 int error;
248 error = xfs_iomap_write_unwritten(ip, offset, size);
249 if (error)
250 ioend->io_error = error;
251 }
248 xfs_setfilesize(ioend); 252 xfs_setfilesize(ioend);
249 } 253 }
250 xfs_destroy_ioend(ioend); 254 xfs_destroy_ioend(ioend);
@@ -1532,9 +1536,9 @@ xfs_vm_bmap(
1532 struct xfs_inode *ip = XFS_I(inode); 1536 struct xfs_inode *ip = XFS_I(inode);
1533 1537
1534 xfs_itrace_entry(XFS_I(inode)); 1538 xfs_itrace_entry(XFS_I(inode));
1535 xfs_rwlock(ip, VRWLOCK_READ); 1539 xfs_ilock(ip, XFS_IOLOCK_SHARED);
1536 xfs_flush_pages(ip, (xfs_off_t)0, -1, 0, FI_REMAPF); 1540 xfs_flush_pages(ip, (xfs_off_t)0, -1, 0, FI_REMAPF);
1537 xfs_rwunlock(ip, VRWLOCK_READ); 1541 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1538 return generic_block_bmap(mapping, block, xfs_get_blocks); 1542 return generic_block_bmap(mapping, block, xfs_get_blocks);
1539} 1543}
1540 1544
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index e347bfd47c91..52f6846101d5 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -400,7 +400,7 @@ _xfs_buf_lookup_pages(
400 printk(KERN_ERR 400 printk(KERN_ERR
401 "XFS: possible memory allocation " 401 "XFS: possible memory allocation "
402 "deadlock in %s (mode:0x%x)\n", 402 "deadlock in %s (mode:0x%x)\n",
403 __FUNCTION__, gfp_mask); 403 __func__, gfp_mask);
404 404
405 XFS_STATS_INC(xb_page_retries); 405 XFS_STATS_INC(xb_page_retries);
406 xfsbufd_wakeup(0, gfp_mask); 406 xfsbufd_wakeup(0, gfp_mask);
@@ -598,7 +598,7 @@ xfs_buf_get_flags(
598 error = _xfs_buf_map_pages(bp, flags); 598 error = _xfs_buf_map_pages(bp, flags);
599 if (unlikely(error)) { 599 if (unlikely(error)) {
600 printk(KERN_WARNING "%s: failed to map pages\n", 600 printk(KERN_WARNING "%s: failed to map pages\n",
601 __FUNCTION__); 601 __func__);
602 goto no_buffer; 602 goto no_buffer;
603 } 603 }
604 } 604 }
@@ -778,7 +778,7 @@ xfs_buf_get_noaddr(
778 error = _xfs_buf_map_pages(bp, XBF_MAPPED); 778 error = _xfs_buf_map_pages(bp, XBF_MAPPED);
779 if (unlikely(error)) { 779 if (unlikely(error)) {
780 printk(KERN_WARNING "%s: failed to map pages\n", 780 printk(KERN_WARNING "%s: failed to map pages\n",
781 __FUNCTION__); 781 __func__);
782 goto fail_free_mem; 782 goto fail_free_mem;
783 } 783 }
784 784
@@ -1060,7 +1060,7 @@ xfs_buf_iostart(
1060 bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC); 1060 bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC);
1061 bp->b_flags |= flags & (XBF_DELWRI | XBF_ASYNC); 1061 bp->b_flags |= flags & (XBF_DELWRI | XBF_ASYNC);
1062 xfs_buf_delwri_queue(bp, 1); 1062 xfs_buf_delwri_queue(bp, 1);
1063 return status; 1063 return 0;
1064 } 1064 }
1065 1065
1066 bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC | XBF_DELWRI | \ 1066 bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_ASYNC | XBF_DELWRI | \
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index a3d207de48b8..841d7883528d 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -387,11 +387,15 @@ static inline int XFS_bwrite(xfs_buf_t *bp)
387 return error; 387 return error;
388} 388}
389 389
390static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp) 390/*
391 * No error can be returned from xfs_buf_iostart for delwri
392 * buffers as they are queued and no I/O is issued.
393 */
394static inline void xfs_bdwrite(void *mp, xfs_buf_t *bp)
391{ 395{
392 bp->b_strat = xfs_bdstrat_cb; 396 bp->b_strat = xfs_bdstrat_cb;
393 bp->b_fspriv3 = mp; 397 bp->b_fspriv3 = mp;
394 return xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC); 398 (void)xfs_buf_iostart(bp, XBF_DELWRI | XBF_ASYNC);
395} 399}
396 400
397#define XFS_bdstrat(bp) xfs_buf_iorequest(bp) 401#define XFS_bdstrat(bp) xfs_buf_iorequest(bp)
diff --git a/fs/xfs/linux-2.6/xfs_cred.h b/fs/xfs/linux-2.6/xfs_cred.h
index e7f3da61c6c3..652721ce0ea5 100644
--- a/fs/xfs/linux-2.6/xfs_cred.h
+++ b/fs/xfs/linux-2.6/xfs_cred.h
@@ -30,7 +30,7 @@ typedef struct cred {
30extern struct cred *sys_cred; 30extern struct cred *sys_cred;
31 31
32/* this is a hack.. (assumes sys_cred is the only cred_t in the system) */ 32/* this is a hack.. (assumes sys_cred is the only cred_t in the system) */
33static __inline int capable_cred(cred_t *cr, int cid) 33static inline int capable_cred(cred_t *cr, int cid)
34{ 34{
35 return (cr == sys_cred) ? 1 : capable(cid); 35 return (cr == sys_cred) ? 1 : capable(cid);
36} 36}
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index ca4f66c4de16..265f0168ab76 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -22,6 +22,7 @@
22#include "xfs_trans.h" 22#include "xfs_trans.h"
23#include "xfs_sb.h" 23#include "xfs_sb.h"
24#include "xfs_ag.h" 24#include "xfs_ag.h"
25#include "xfs_dir2.h"
25#include "xfs_dmapi.h" 26#include "xfs_dmapi.h"
26#include "xfs_mount.h" 27#include "xfs_mount.h"
27#include "xfs_export.h" 28#include "xfs_export.h"
@@ -30,8 +31,6 @@
30#include "xfs_inode.h" 31#include "xfs_inode.h"
31#include "xfs_vfsops.h" 32#include "xfs_vfsops.h"
32 33
33static struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, };
34
35/* 34/*
36 * Note that we only accept fileids which are long enough rather than allow 35 * Note that we only accept fileids which are long enough rather than allow
37 * the parent generation number to default to zero. XFS considers zero a 36 * the parent generation number to default to zero. XFS considers zero a
@@ -66,7 +65,7 @@ xfs_fs_encode_fh(
66 int len; 65 int len;
67 66
68 /* Directories don't need their parent encoded, they have ".." */ 67 /* Directories don't need their parent encoded, they have ".." */
69 if (S_ISDIR(inode->i_mode)) 68 if (S_ISDIR(inode->i_mode) || !connectable)
70 fileid_type = FILEID_INO32_GEN; 69 fileid_type = FILEID_INO32_GEN;
71 else 70 else
72 fileid_type = FILEID_INO32_GEN_PARENT; 71 fileid_type = FILEID_INO32_GEN_PARENT;
@@ -213,17 +212,16 @@ xfs_fs_get_parent(
213 struct dentry *child) 212 struct dentry *child)
214{ 213{
215 int error; 214 int error;
216 bhv_vnode_t *cvp; 215 struct xfs_inode *cip;
217 struct dentry *parent; 216 struct dentry *parent;
218 217
219 cvp = NULL; 218 error = xfs_lookup(XFS_I(child->d_inode), &xfs_name_dotdot, &cip);
220 error = xfs_lookup(XFS_I(child->d_inode), &dotdot, &cvp);
221 if (unlikely(error)) 219 if (unlikely(error))
222 return ERR_PTR(-error); 220 return ERR_PTR(-error);
223 221
224 parent = d_alloc_anon(vn_to_inode(cvp)); 222 parent = d_alloc_anon(cip->i_vnode);
225 if (unlikely(!parent)) { 223 if (unlikely(!parent)) {
226 VN_RELE(cvp); 224 iput(cip->i_vnode);
227 return ERR_PTR(-ENOMEM); 225 return ERR_PTR(-ENOMEM);
228 } 226 }
229 return parent; 227 return parent;
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index edab1ffbb163..05905246434d 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -469,16 +469,11 @@ xfs_file_open_exec(
469 struct inode *inode) 469 struct inode *inode)
470{ 470{
471 struct xfs_mount *mp = XFS_M(inode->i_sb); 471 struct xfs_mount *mp = XFS_M(inode->i_sb);
472 struct xfs_inode *ip = XFS_I(inode);
472 473
473 if (unlikely(mp->m_flags & XFS_MOUNT_DMAPI)) { 474 if (unlikely(mp->m_flags & XFS_MOUNT_DMAPI) &&
474 if (DM_EVENT_ENABLED(XFS_I(inode), DM_EVENT_READ)) { 475 DM_EVENT_ENABLED(ip, DM_EVENT_READ))
475 bhv_vnode_t *vp = vn_from_inode(inode); 476 return -XFS_SEND_DATA(mp, DM_EVENT_READ, ip, 0, 0, 0, NULL);
476
477 return -XFS_SEND_DATA(mp, DM_EVENT_READ,
478 vp, 0, 0, 0, NULL);
479 }
480 }
481
482 return 0; 477 return 0;
483} 478}
484#endif /* HAVE_FOP_OPEN_EXEC */ 479#endif /* HAVE_FOP_OPEN_EXEC */
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index ac6d34cc355d..1eefe61f0e10 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -17,18 +17,7 @@
17 */ 17 */
18#include "xfs.h" 18#include "xfs.h"
19#include "xfs_vnodeops.h" 19#include "xfs_vnodeops.h"
20
21/*
22 * The following six includes are needed so that we can include
23 * xfs_inode.h. What a mess..
24 */
25#include "xfs_bmap_btree.h" 20#include "xfs_bmap_btree.h"
26#include "xfs_inum.h"
27#include "xfs_dir2.h"
28#include "xfs_dir2_sf.h"
29#include "xfs_attr_sf.h"
30#include "xfs_dinode.h"
31
32#include "xfs_inode.h" 21#include "xfs_inode.h"
33 22
34int fs_noerr(void) { return 0; } 23int fs_noerr(void) { return 0; }
@@ -42,11 +31,10 @@ xfs_tosspages(
42 xfs_off_t last, 31 xfs_off_t last,
43 int fiopt) 32 int fiopt)
44{ 33{
45 bhv_vnode_t *vp = XFS_ITOV(ip); 34 struct address_space *mapping = ip->i_vnode->i_mapping;
46 struct inode *inode = vn_to_inode(vp);
47 35
48 if (VN_CACHED(vp)) 36 if (mapping->nrpages)
49 truncate_inode_pages(inode->i_mapping, first); 37 truncate_inode_pages(mapping, first);
50} 38}
51 39
52int 40int
@@ -56,15 +44,14 @@ xfs_flushinval_pages(
56 xfs_off_t last, 44 xfs_off_t last,
57 int fiopt) 45 int fiopt)
58{ 46{
59 bhv_vnode_t *vp = XFS_ITOV(ip); 47 struct address_space *mapping = ip->i_vnode->i_mapping;
60 struct inode *inode = vn_to_inode(vp);
61 int ret = 0; 48 int ret = 0;
62 49
63 if (VN_CACHED(vp)) { 50 if (mapping->nrpages) {
64 xfs_iflags_clear(ip, XFS_ITRUNCATED); 51 xfs_iflags_clear(ip, XFS_ITRUNCATED);
65 ret = filemap_write_and_wait(inode->i_mapping); 52 ret = filemap_write_and_wait(mapping);
66 if (!ret) 53 if (!ret)
67 truncate_inode_pages(inode->i_mapping, first); 54 truncate_inode_pages(mapping, first);
68 } 55 }
69 return ret; 56 return ret;
70} 57}
@@ -77,17 +64,16 @@ xfs_flush_pages(
77 uint64_t flags, 64 uint64_t flags,
78 int fiopt) 65 int fiopt)
79{ 66{
80 bhv_vnode_t *vp = XFS_ITOV(ip); 67 struct address_space *mapping = ip->i_vnode->i_mapping;
81 struct inode *inode = vn_to_inode(vp);
82 int ret = 0; 68 int ret = 0;
83 int ret2; 69 int ret2;
84 70
85 if (VN_DIRTY(vp)) { 71 if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
86 xfs_iflags_clear(ip, XFS_ITRUNCATED); 72 xfs_iflags_clear(ip, XFS_ITRUNCATED);
87 ret = filemap_fdatawrite(inode->i_mapping); 73 ret = filemap_fdatawrite(mapping);
88 if (flags & XFS_B_ASYNC) 74 if (flags & XFS_B_ASYNC)
89 return ret; 75 return ret;
90 ret2 = filemap_fdatawait(inode->i_mapping); 76 ret2 = filemap_fdatawait(mapping);
91 if (!ret) 77 if (!ret)
92 ret = ret2; 78 ret = ret2;
93 } 79 }
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index f34bd010eb51..bf7759793856 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -651,314 +651,6 @@ xfs_attrmulti_by_handle(
651 return -error; 651 return -error;
652} 652}
653 653
654/* prototypes for a few of the stack-hungry cases that have
655 * their own functions. Functions are defined after their use
656 * so gcc doesn't get fancy and inline them with -03 */
657
658STATIC int
659xfs_ioc_space(
660 struct xfs_inode *ip,
661 struct inode *inode,
662 struct file *filp,
663 int flags,
664 unsigned int cmd,
665 void __user *arg);
666
667STATIC int
668xfs_ioc_bulkstat(
669 xfs_mount_t *mp,
670 unsigned int cmd,
671 void __user *arg);
672
673STATIC int
674xfs_ioc_fsgeometry_v1(
675 xfs_mount_t *mp,
676 void __user *arg);
677
678STATIC int
679xfs_ioc_fsgeometry(
680 xfs_mount_t *mp,
681 void __user *arg);
682
683STATIC int
684xfs_ioc_xattr(
685 xfs_inode_t *ip,
686 struct file *filp,
687 unsigned int cmd,
688 void __user *arg);
689
690STATIC int
691xfs_ioc_fsgetxattr(
692 xfs_inode_t *ip,
693 int attr,
694 void __user *arg);
695
696STATIC int
697xfs_ioc_getbmap(
698 struct xfs_inode *ip,
699 int flags,
700 unsigned int cmd,
701 void __user *arg);
702
703STATIC int
704xfs_ioc_getbmapx(
705 struct xfs_inode *ip,
706 void __user *arg);
707
708int
709xfs_ioctl(
710 xfs_inode_t *ip,
711 struct file *filp,
712 int ioflags,
713 unsigned int cmd,
714 void __user *arg)
715{
716 struct inode *inode = filp->f_path.dentry->d_inode;
717 xfs_mount_t *mp = ip->i_mount;
718 int error;
719
720 xfs_itrace_entry(XFS_I(inode));
721 switch (cmd) {
722
723 case XFS_IOC_ALLOCSP:
724 case XFS_IOC_FREESP:
725 case XFS_IOC_RESVSP:
726 case XFS_IOC_UNRESVSP:
727 case XFS_IOC_ALLOCSP64:
728 case XFS_IOC_FREESP64:
729 case XFS_IOC_RESVSP64:
730 case XFS_IOC_UNRESVSP64:
731 /*
732 * Only allow the sys admin to reserve space unless
733 * unwritten extents are enabled.
734 */
735 if (!xfs_sb_version_hasextflgbit(&mp->m_sb) &&
736 !capable(CAP_SYS_ADMIN))
737 return -EPERM;
738
739 return xfs_ioc_space(ip, inode, filp, ioflags, cmd, arg);
740
741 case XFS_IOC_DIOINFO: {
742 struct dioattr da;
743 xfs_buftarg_t *target =
744 XFS_IS_REALTIME_INODE(ip) ?
745 mp->m_rtdev_targp : mp->m_ddev_targp;
746
747 da.d_mem = da.d_miniosz = 1 << target->bt_sshift;
748 da.d_maxiosz = INT_MAX & ~(da.d_miniosz - 1);
749
750 if (copy_to_user(arg, &da, sizeof(da)))
751 return -XFS_ERROR(EFAULT);
752 return 0;
753 }
754
755 case XFS_IOC_FSBULKSTAT_SINGLE:
756 case XFS_IOC_FSBULKSTAT:
757 case XFS_IOC_FSINUMBERS:
758 return xfs_ioc_bulkstat(mp, cmd, arg);
759
760 case XFS_IOC_FSGEOMETRY_V1:
761 return xfs_ioc_fsgeometry_v1(mp, arg);
762
763 case XFS_IOC_FSGEOMETRY:
764 return xfs_ioc_fsgeometry(mp, arg);
765
766 case XFS_IOC_GETVERSION:
767 return put_user(inode->i_generation, (int __user *)arg);
768
769 case XFS_IOC_FSGETXATTR:
770 return xfs_ioc_fsgetxattr(ip, 0, arg);
771 case XFS_IOC_FSGETXATTRA:
772 return xfs_ioc_fsgetxattr(ip, 1, arg);
773 case XFS_IOC_GETXFLAGS:
774 case XFS_IOC_SETXFLAGS:
775 case XFS_IOC_FSSETXATTR:
776 return xfs_ioc_xattr(ip, filp, cmd, arg);
777
778 case XFS_IOC_FSSETDM: {
779 struct fsdmidata dmi;
780
781 if (copy_from_user(&dmi, arg, sizeof(dmi)))
782 return -XFS_ERROR(EFAULT);
783
784 error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask,
785 dmi.fsd_dmstate);
786 return -error;
787 }
788
789 case XFS_IOC_GETBMAP:
790 case XFS_IOC_GETBMAPA:
791 return xfs_ioc_getbmap(ip, ioflags, cmd, arg);
792
793 case XFS_IOC_GETBMAPX:
794 return xfs_ioc_getbmapx(ip, arg);
795
796 case XFS_IOC_FD_TO_HANDLE:
797 case XFS_IOC_PATH_TO_HANDLE:
798 case XFS_IOC_PATH_TO_FSHANDLE:
799 return xfs_find_handle(cmd, arg);
800
801 case XFS_IOC_OPEN_BY_HANDLE:
802 return xfs_open_by_handle(mp, arg, filp, inode);
803
804 case XFS_IOC_FSSETDM_BY_HANDLE:
805 return xfs_fssetdm_by_handle(mp, arg, inode);
806
807 case XFS_IOC_READLINK_BY_HANDLE:
808 return xfs_readlink_by_handle(mp, arg, inode);
809
810 case XFS_IOC_ATTRLIST_BY_HANDLE:
811 return xfs_attrlist_by_handle(mp, arg, inode);
812
813 case XFS_IOC_ATTRMULTI_BY_HANDLE:
814 return xfs_attrmulti_by_handle(mp, arg, inode);
815
816 case XFS_IOC_SWAPEXT: {
817 error = xfs_swapext((struct xfs_swapext __user *)arg);
818 return -error;
819 }
820
821 case XFS_IOC_FSCOUNTS: {
822 xfs_fsop_counts_t out;
823
824 error = xfs_fs_counts(mp, &out);
825 if (error)
826 return -error;
827
828 if (copy_to_user(arg, &out, sizeof(out)))
829 return -XFS_ERROR(EFAULT);
830 return 0;
831 }
832
833 case XFS_IOC_SET_RESBLKS: {
834 xfs_fsop_resblks_t inout;
835 __uint64_t in;
836
837 if (!capable(CAP_SYS_ADMIN))
838 return -EPERM;
839
840 if (copy_from_user(&inout, arg, sizeof(inout)))
841 return -XFS_ERROR(EFAULT);
842
843 /* input parameter is passed in resblks field of structure */
844 in = inout.resblks;
845 error = xfs_reserve_blocks(mp, &in, &inout);
846 if (error)
847 return -error;
848
849 if (copy_to_user(arg, &inout, sizeof(inout)))
850 return -XFS_ERROR(EFAULT);
851 return 0;
852 }
853
854 case XFS_IOC_GET_RESBLKS: {
855 xfs_fsop_resblks_t out;
856
857 if (!capable(CAP_SYS_ADMIN))
858 return -EPERM;
859
860 error = xfs_reserve_blocks(mp, NULL, &out);
861 if (error)
862 return -error;
863
864 if (copy_to_user(arg, &out, sizeof(out)))
865 return -XFS_ERROR(EFAULT);
866
867 return 0;
868 }
869
870 case XFS_IOC_FSGROWFSDATA: {
871 xfs_growfs_data_t in;
872
873 if (!capable(CAP_SYS_ADMIN))
874 return -EPERM;
875
876 if (copy_from_user(&in, arg, sizeof(in)))
877 return -XFS_ERROR(EFAULT);
878
879 error = xfs_growfs_data(mp, &in);
880 return -error;
881 }
882
883 case XFS_IOC_FSGROWFSLOG: {
884 xfs_growfs_log_t in;
885
886 if (!capable(CAP_SYS_ADMIN))
887 return -EPERM;
888
889 if (copy_from_user(&in, arg, sizeof(in)))
890 return -XFS_ERROR(EFAULT);
891
892 error = xfs_growfs_log(mp, &in);
893 return -error;
894 }
895
896 case XFS_IOC_FSGROWFSRT: {
897 xfs_growfs_rt_t in;
898
899 if (!capable(CAP_SYS_ADMIN))
900 return -EPERM;
901
902 if (copy_from_user(&in, arg, sizeof(in)))
903 return -XFS_ERROR(EFAULT);
904
905 error = xfs_growfs_rt(mp, &in);
906 return -error;
907 }
908
909 case XFS_IOC_FREEZE:
910 if (!capable(CAP_SYS_ADMIN))
911 return -EPERM;
912
913 if (inode->i_sb->s_frozen == SB_UNFROZEN)
914 freeze_bdev(inode->i_sb->s_bdev);
915 return 0;
916
917 case XFS_IOC_THAW:
918 if (!capable(CAP_SYS_ADMIN))
919 return -EPERM;
920 if (inode->i_sb->s_frozen != SB_UNFROZEN)
921 thaw_bdev(inode->i_sb->s_bdev, inode->i_sb);
922 return 0;
923
924 case XFS_IOC_GOINGDOWN: {
925 __uint32_t in;
926
927 if (!capable(CAP_SYS_ADMIN))
928 return -EPERM;
929
930 if (get_user(in, (__uint32_t __user *)arg))
931 return -XFS_ERROR(EFAULT);
932
933 error = xfs_fs_goingdown(mp, in);
934 return -error;
935 }
936
937 case XFS_IOC_ERROR_INJECTION: {
938 xfs_error_injection_t in;
939
940 if (!capable(CAP_SYS_ADMIN))
941 return -EPERM;
942
943 if (copy_from_user(&in, arg, sizeof(in)))
944 return -XFS_ERROR(EFAULT);
945
946 error = xfs_errortag_add(in.errtag, mp);
947 return -error;
948 }
949
950 case XFS_IOC_ERROR_CLEARALL:
951 if (!capable(CAP_SYS_ADMIN))
952 return -EPERM;
953
954 error = xfs_errortag_clearall(mp, 1);
955 return -error;
956
957 default:
958 return -ENOTTY;
959 }
960}
961
962STATIC int 654STATIC int
963xfs_ioc_space( 655xfs_ioc_space(
964 struct xfs_inode *ip, 656 struct xfs_inode *ip,
@@ -1179,85 +871,85 @@ xfs_ioc_fsgetxattr(
1179} 871}
1180 872
1181STATIC int 873STATIC int
1182xfs_ioc_xattr( 874xfs_ioc_fssetxattr(
1183 xfs_inode_t *ip, 875 xfs_inode_t *ip,
1184 struct file *filp, 876 struct file *filp,
1185 unsigned int cmd,
1186 void __user *arg) 877 void __user *arg)
1187{ 878{
1188 struct fsxattr fa; 879 struct fsxattr fa;
1189 struct bhv_vattr *vattr; 880 struct bhv_vattr *vattr;
1190 int error = 0; 881 int error;
1191 int attr_flags; 882 int attr_flags;
1192 unsigned int flags; 883
884 if (copy_from_user(&fa, arg, sizeof(fa)))
885 return -EFAULT;
1193 886
1194 vattr = kmalloc(sizeof(*vattr), GFP_KERNEL); 887 vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
1195 if (unlikely(!vattr)) 888 if (unlikely(!vattr))
1196 return -ENOMEM; 889 return -ENOMEM;
1197 890
1198 switch (cmd) { 891 attr_flags = 0;
1199 case XFS_IOC_FSSETXATTR: { 892 if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
1200 if (copy_from_user(&fa, arg, sizeof(fa))) { 893 attr_flags |= ATTR_NONBLOCK;
1201 error = -EFAULT;
1202 break;
1203 }
1204 894
1205 attr_flags = 0; 895 vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID;
1206 if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) 896 vattr->va_xflags = fa.fsx_xflags;
1207 attr_flags |= ATTR_NONBLOCK; 897 vattr->va_extsize = fa.fsx_extsize;
898 vattr->va_projid = fa.fsx_projid;
1208 899
1209 vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID; 900 error = -xfs_setattr(ip, vattr, attr_flags, NULL);
1210 vattr->va_xflags = fa.fsx_xflags; 901 if (!error)
1211 vattr->va_extsize = fa.fsx_extsize; 902 vn_revalidate(XFS_ITOV(ip)); /* update flags */
1212 vattr->va_projid = fa.fsx_projid; 903 kfree(vattr);
904 return 0;
905}
1213 906
1214 error = xfs_setattr(ip, vattr, attr_flags, NULL); 907STATIC int
1215 if (likely(!error)) 908xfs_ioc_getxflags(
1216 vn_revalidate(XFS_ITOV(ip)); /* update flags */ 909 xfs_inode_t *ip,
1217 error = -error; 910 void __user *arg)
1218 break; 911{
1219 } 912 unsigned int flags;
1220 913
1221 case XFS_IOC_GETXFLAGS: { 914 flags = xfs_di2lxflags(ip->i_d.di_flags);
1222 flags = xfs_di2lxflags(ip->i_d.di_flags); 915 if (copy_to_user(arg, &flags, sizeof(flags)))
1223 if (copy_to_user(arg, &flags, sizeof(flags))) 916 return -EFAULT;
1224 error = -EFAULT; 917 return 0;
1225 break; 918}
1226 }
1227 919
1228 case XFS_IOC_SETXFLAGS: { 920STATIC int
1229 if (copy_from_user(&flags, arg, sizeof(flags))) { 921xfs_ioc_setxflags(
1230 error = -EFAULT; 922 xfs_inode_t *ip,
1231 break; 923 struct file *filp,
1232 } 924 void __user *arg)
925{
926 struct bhv_vattr *vattr;
927 unsigned int flags;
928 int attr_flags;
929 int error;
1233 930
1234 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \ 931 if (copy_from_user(&flags, arg, sizeof(flags)))
1235 FS_NOATIME_FL | FS_NODUMP_FL | \ 932 return -EFAULT;
1236 FS_SYNC_FL)) {
1237 error = -EOPNOTSUPP;
1238 break;
1239 }
1240 933
1241 attr_flags = 0; 934 if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
1242 if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) 935 FS_NOATIME_FL | FS_NODUMP_FL | \
1243 attr_flags |= ATTR_NONBLOCK; 936 FS_SYNC_FL))
937 return -EOPNOTSUPP;
1244 938
1245 vattr->va_mask = XFS_AT_XFLAGS; 939 vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
1246 vattr->va_xflags = xfs_merge_ioc_xflags(flags, 940 if (unlikely(!vattr))
1247 xfs_ip2xflags(ip)); 941 return -ENOMEM;
1248 942
1249 error = xfs_setattr(ip, vattr, attr_flags, NULL); 943 attr_flags = 0;
1250 if (likely(!error)) 944 if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
1251 vn_revalidate(XFS_ITOV(ip)); /* update flags */ 945 attr_flags |= ATTR_NONBLOCK;
1252 error = -error;
1253 break;
1254 }
1255 946
1256 default: 947 vattr->va_mask = XFS_AT_XFLAGS;
1257 error = -ENOTTY; 948 vattr->va_xflags = xfs_merge_ioc_xflags(flags, xfs_ip2xflags(ip));
1258 break;
1259 }
1260 949
950 error = -xfs_setattr(ip, vattr, attr_flags, NULL);
951 if (likely(!error))
952 vn_revalidate(XFS_ITOV(ip)); /* update flags */
1261 kfree(vattr); 953 kfree(vattr);
1262 return error; 954 return error;
1263} 955}
@@ -1332,3 +1024,259 @@ xfs_ioc_getbmapx(
1332 1024
1333 return 0; 1025 return 0;
1334} 1026}
1027
1028int
1029xfs_ioctl(
1030 xfs_inode_t *ip,
1031 struct file *filp,
1032 int ioflags,
1033 unsigned int cmd,
1034 void __user *arg)
1035{
1036 struct inode *inode = filp->f_path.dentry->d_inode;
1037 xfs_mount_t *mp = ip->i_mount;
1038 int error;
1039
1040 xfs_itrace_entry(XFS_I(inode));
1041 switch (cmd) {
1042
1043 case XFS_IOC_ALLOCSP:
1044 case XFS_IOC_FREESP:
1045 case XFS_IOC_RESVSP:
1046 case XFS_IOC_UNRESVSP:
1047 case XFS_IOC_ALLOCSP64:
1048 case XFS_IOC_FREESP64:
1049 case XFS_IOC_RESVSP64:
1050 case XFS_IOC_UNRESVSP64:
1051 /*
1052 * Only allow the sys admin to reserve space unless
1053 * unwritten extents are enabled.
1054 */
1055 if (!xfs_sb_version_hasextflgbit(&mp->m_sb) &&
1056 !capable(CAP_SYS_ADMIN))
1057 return -EPERM;
1058
1059 return xfs_ioc_space(ip, inode, filp, ioflags, cmd, arg);
1060
1061 case XFS_IOC_DIOINFO: {
1062 struct dioattr da;
1063 xfs_buftarg_t *target =
1064 XFS_IS_REALTIME_INODE(ip) ?
1065 mp->m_rtdev_targp : mp->m_ddev_targp;
1066
1067 da.d_mem = da.d_miniosz = 1 << target->bt_sshift;
1068 da.d_maxiosz = INT_MAX & ~(da.d_miniosz - 1);
1069
1070 if (copy_to_user(arg, &da, sizeof(da)))
1071 return -XFS_ERROR(EFAULT);
1072 return 0;
1073 }
1074
1075 case XFS_IOC_FSBULKSTAT_SINGLE:
1076 case XFS_IOC_FSBULKSTAT:
1077 case XFS_IOC_FSINUMBERS:
1078 return xfs_ioc_bulkstat(mp, cmd, arg);
1079
1080 case XFS_IOC_FSGEOMETRY_V1:
1081 return xfs_ioc_fsgeometry_v1(mp, arg);
1082
1083 case XFS_IOC_FSGEOMETRY:
1084 return xfs_ioc_fsgeometry(mp, arg);
1085
1086 case XFS_IOC_GETVERSION:
1087 return put_user(inode->i_generation, (int __user *)arg);
1088
1089 case XFS_IOC_FSGETXATTR:
1090 return xfs_ioc_fsgetxattr(ip, 0, arg);
1091 case XFS_IOC_FSGETXATTRA:
1092 return xfs_ioc_fsgetxattr(ip, 1, arg);
1093 case XFS_IOC_FSSETXATTR:
1094 return xfs_ioc_fssetxattr(ip, filp, arg);
1095 case XFS_IOC_GETXFLAGS:
1096 return xfs_ioc_getxflags(ip, arg);
1097 case XFS_IOC_SETXFLAGS:
1098 return xfs_ioc_setxflags(ip, filp, arg);
1099
1100 case XFS_IOC_FSSETDM: {
1101 struct fsdmidata dmi;
1102
1103 if (copy_from_user(&dmi, arg, sizeof(dmi)))
1104 return -XFS_ERROR(EFAULT);
1105
1106 error = xfs_set_dmattrs(ip, dmi.fsd_dmevmask,
1107 dmi.fsd_dmstate);
1108 return -error;
1109 }
1110
1111 case XFS_IOC_GETBMAP:
1112 case XFS_IOC_GETBMAPA:
1113 return xfs_ioc_getbmap(ip, ioflags, cmd, arg);
1114
1115 case XFS_IOC_GETBMAPX:
1116 return xfs_ioc_getbmapx(ip, arg);
1117
1118 case XFS_IOC_FD_TO_HANDLE:
1119 case XFS_IOC_PATH_TO_HANDLE:
1120 case XFS_IOC_PATH_TO_FSHANDLE:
1121 return xfs_find_handle(cmd, arg);
1122
1123 case XFS_IOC_OPEN_BY_HANDLE:
1124 return xfs_open_by_handle(mp, arg, filp, inode);
1125
1126 case XFS_IOC_FSSETDM_BY_HANDLE:
1127 return xfs_fssetdm_by_handle(mp, arg, inode);
1128
1129 case XFS_IOC_READLINK_BY_HANDLE:
1130 return xfs_readlink_by_handle(mp, arg, inode);
1131
1132 case XFS_IOC_ATTRLIST_BY_HANDLE:
1133 return xfs_attrlist_by_handle(mp, arg, inode);
1134
1135 case XFS_IOC_ATTRMULTI_BY_HANDLE:
1136 return xfs_attrmulti_by_handle(mp, arg, inode);
1137
1138 case XFS_IOC_SWAPEXT: {
1139 error = xfs_swapext((struct xfs_swapext __user *)arg);
1140 return -error;
1141 }
1142
1143 case XFS_IOC_FSCOUNTS: {
1144 xfs_fsop_counts_t out;
1145
1146 error = xfs_fs_counts(mp, &out);
1147 if (error)
1148 return -error;
1149
1150 if (copy_to_user(arg, &out, sizeof(out)))
1151 return -XFS_ERROR(EFAULT);
1152 return 0;
1153 }
1154
1155 case XFS_IOC_SET_RESBLKS: {
1156 xfs_fsop_resblks_t inout;
1157 __uint64_t in;
1158
1159 if (!capable(CAP_SYS_ADMIN))
1160 return -EPERM;
1161
1162 if (copy_from_user(&inout, arg, sizeof(inout)))
1163 return -XFS_ERROR(EFAULT);
1164
1165 /* input parameter is passed in resblks field of structure */
1166 in = inout.resblks;
1167 error = xfs_reserve_blocks(mp, &in, &inout);
1168 if (error)
1169 return -error;
1170
1171 if (copy_to_user(arg, &inout, sizeof(inout)))
1172 return -XFS_ERROR(EFAULT);
1173 return 0;
1174 }
1175
1176 case XFS_IOC_GET_RESBLKS: {
1177 xfs_fsop_resblks_t out;
1178
1179 if (!capable(CAP_SYS_ADMIN))
1180 return -EPERM;
1181
1182 error = xfs_reserve_blocks(mp, NULL, &out);
1183 if (error)
1184 return -error;
1185
1186 if (copy_to_user(arg, &out, sizeof(out)))
1187 return -XFS_ERROR(EFAULT);
1188
1189 return 0;
1190 }
1191
1192 case XFS_IOC_FSGROWFSDATA: {
1193 xfs_growfs_data_t in;
1194
1195 if (!capable(CAP_SYS_ADMIN))
1196 return -EPERM;
1197
1198 if (copy_from_user(&in, arg, sizeof(in)))
1199 return -XFS_ERROR(EFAULT);
1200
1201 error = xfs_growfs_data(mp, &in);
1202 return -error;
1203 }
1204
1205 case XFS_IOC_FSGROWFSLOG: {
1206 xfs_growfs_log_t in;
1207
1208 if (!capable(CAP_SYS_ADMIN))
1209 return -EPERM;
1210
1211 if (copy_from_user(&in, arg, sizeof(in)))
1212 return -XFS_ERROR(EFAULT);
1213
1214 error = xfs_growfs_log(mp, &in);
1215 return -error;
1216 }
1217
1218 case XFS_IOC_FSGROWFSRT: {
1219 xfs_growfs_rt_t in;
1220
1221 if (!capable(CAP_SYS_ADMIN))
1222 return -EPERM;
1223
1224 if (copy_from_user(&in, arg, sizeof(in)))
1225 return -XFS_ERROR(EFAULT);
1226
1227 error = xfs_growfs_rt(mp, &in);
1228 return -error;
1229 }
1230
1231 case XFS_IOC_FREEZE:
1232 if (!capable(CAP_SYS_ADMIN))
1233 return -EPERM;
1234
1235 if (inode->i_sb->s_frozen == SB_UNFROZEN)
1236 freeze_bdev(inode->i_sb->s_bdev);
1237 return 0;
1238
1239 case XFS_IOC_THAW:
1240 if (!capable(CAP_SYS_ADMIN))
1241 return -EPERM;
1242 if (inode->i_sb->s_frozen != SB_UNFROZEN)
1243 thaw_bdev(inode->i_sb->s_bdev, inode->i_sb);
1244 return 0;
1245
1246 case XFS_IOC_GOINGDOWN: {
1247 __uint32_t in;
1248
1249 if (!capable(CAP_SYS_ADMIN))
1250 return -EPERM;
1251
1252 if (get_user(in, (__uint32_t __user *)arg))
1253 return -XFS_ERROR(EFAULT);
1254
1255 error = xfs_fs_goingdown(mp, in);
1256 return -error;
1257 }
1258
1259 case XFS_IOC_ERROR_INJECTION: {
1260 xfs_error_injection_t in;
1261
1262 if (!capable(CAP_SYS_ADMIN))
1263 return -EPERM;
1264
1265 if (copy_from_user(&in, arg, sizeof(in)))
1266 return -XFS_ERROR(EFAULT);
1267
1268 error = xfs_errortag_add(in.errtag, mp);
1269 return -error;
1270 }
1271
1272 case XFS_IOC_ERROR_CLEARALL:
1273 if (!capable(CAP_SYS_ADMIN))
1274 return -EPERM;
1275
1276 error = xfs_errortag_clearall(mp, 1);
1277 return -error;
1278
1279 default:
1280 return -ENOTTY;
1281 }
1282}
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index cc4abd3daa49..0c958cf77758 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -62,12 +62,11 @@ void
62xfs_synchronize_atime( 62xfs_synchronize_atime(
63 xfs_inode_t *ip) 63 xfs_inode_t *ip)
64{ 64{
65 bhv_vnode_t *vp; 65 struct inode *inode = ip->i_vnode;
66 66
67 vp = XFS_ITOV_NULL(ip); 67 if (inode) {
68 if (vp) { 68 ip->i_d.di_atime.t_sec = (__int32_t)inode->i_atime.tv_sec;
69 ip->i_d.di_atime.t_sec = (__int32_t)vp->i_atime.tv_sec; 69 ip->i_d.di_atime.t_nsec = (__int32_t)inode->i_atime.tv_nsec;
70 ip->i_d.di_atime.t_nsec = (__int32_t)vp->i_atime.tv_nsec;
71 } 70 }
72} 71}
73 72
@@ -80,11 +79,10 @@ void
80xfs_mark_inode_dirty_sync( 79xfs_mark_inode_dirty_sync(
81 xfs_inode_t *ip) 80 xfs_inode_t *ip)
82{ 81{
83 bhv_vnode_t *vp; 82 struct inode *inode = ip->i_vnode;
84 83
85 vp = XFS_ITOV_NULL(ip); 84 if (inode)
86 if (vp) 85 mark_inode_dirty_sync(inode);
87 mark_inode_dirty_sync(vn_to_inode(vp));
88} 86}
89 87
90/* 88/*
@@ -215,66 +213,62 @@ xfs_validate_fields(
215 */ 213 */
216STATIC int 214STATIC int
217xfs_init_security( 215xfs_init_security(
218 bhv_vnode_t *vp, 216 struct inode *inode,
219 struct inode *dir) 217 struct inode *dir)
220{ 218{
221 struct inode *ip = vn_to_inode(vp); 219 struct xfs_inode *ip = XFS_I(inode);
222 size_t length; 220 size_t length;
223 void *value; 221 void *value;
224 char *name; 222 char *name;
225 int error; 223 int error;
226 224
227 error = security_inode_init_security(ip, dir, &name, &value, &length); 225 error = security_inode_init_security(inode, dir, &name,
226 &value, &length);
228 if (error) { 227 if (error) {
229 if (error == -EOPNOTSUPP) 228 if (error == -EOPNOTSUPP)
230 return 0; 229 return 0;
231 return -error; 230 return -error;
232 } 231 }
233 232
234 error = xfs_attr_set(XFS_I(ip), name, value, 233 error = xfs_attr_set(ip, name, value, length, ATTR_SECURE);
235 length, ATTR_SECURE);
236 if (!error) 234 if (!error)
237 xfs_iflags_set(XFS_I(ip), XFS_IMODIFIED); 235 xfs_iflags_set(ip, XFS_IMODIFIED);
238 236
239 kfree(name); 237 kfree(name);
240 kfree(value); 238 kfree(value);
241 return error; 239 return error;
242} 240}
243 241
244/* 242static void
245 * Determine whether a process has a valid fs_struct (kernel daemons 243xfs_dentry_to_name(
246 * like knfsd don't have an fs_struct). 244 struct xfs_name *namep,
247 * 245 struct dentry *dentry)
248 * XXX(hch): nfsd is broken, better fix it instead.
249 */
250STATIC_INLINE int
251xfs_has_fs_struct(struct task_struct *task)
252{ 246{
253 return (task->fs != init_task.fs); 247 namep->name = dentry->d_name.name;
248 namep->len = dentry->d_name.len;
254} 249}
255 250
256STATIC void 251STATIC void
257xfs_cleanup_inode( 252xfs_cleanup_inode(
258 struct inode *dir, 253 struct inode *dir,
259 bhv_vnode_t *vp, 254 struct inode *inode,
260 struct dentry *dentry, 255 struct dentry *dentry,
261 int mode) 256 int mode)
262{ 257{
263 struct dentry teardown = {}; 258 struct xfs_name teardown;
264 259
265 /* Oh, the horror. 260 /* Oh, the horror.
266 * If we can't add the ACL or we fail in 261 * If we can't add the ACL or we fail in
267 * xfs_init_security we must back out. 262 * xfs_init_security we must back out.
268 * ENOSPC can hit here, among other things. 263 * ENOSPC can hit here, among other things.
269 */ 264 */
270 teardown.d_inode = vn_to_inode(vp); 265 xfs_dentry_to_name(&teardown, dentry);
271 teardown.d_name = dentry->d_name;
272 266
273 if (S_ISDIR(mode)) 267 if (S_ISDIR(mode))
274 xfs_rmdir(XFS_I(dir), &teardown); 268 xfs_rmdir(XFS_I(dir), &teardown, XFS_I(inode));
275 else 269 else
276 xfs_remove(XFS_I(dir), &teardown); 270 xfs_remove(XFS_I(dir), &teardown, XFS_I(inode));
277 VN_RELE(vp); 271 iput(inode);
278} 272}
279 273
280STATIC int 274STATIC int
@@ -284,9 +278,10 @@ xfs_vn_mknod(
284 int mode, 278 int mode,
285 dev_t rdev) 279 dev_t rdev)
286{ 280{
287 struct inode *ip; 281 struct inode *inode;
288 bhv_vnode_t *vp = NULL, *dvp = vn_from_inode(dir); 282 struct xfs_inode *ip = NULL;
289 xfs_acl_t *default_acl = NULL; 283 xfs_acl_t *default_acl = NULL;
284 struct xfs_name name;
290 attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; 285 attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
291 int error; 286 int error;
292 287
@@ -297,59 +292,67 @@ xfs_vn_mknod(
297 if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) 292 if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
298 return -EINVAL; 293 return -EINVAL;
299 294
300 if (unlikely(test_default_acl && test_default_acl(dvp))) { 295 if (test_default_acl && test_default_acl(dir)) {
301 if (!_ACL_ALLOC(default_acl)) { 296 if (!_ACL_ALLOC(default_acl)) {
302 return -ENOMEM; 297 return -ENOMEM;
303 } 298 }
304 if (!_ACL_GET_DEFAULT(dvp, default_acl)) { 299 if (!_ACL_GET_DEFAULT(dir, default_acl)) {
305 _ACL_FREE(default_acl); 300 _ACL_FREE(default_acl);
306 default_acl = NULL; 301 default_acl = NULL;
307 } 302 }
308 } 303 }
309 304
310 if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current)) 305 xfs_dentry_to_name(&name, dentry);
306
307 if (IS_POSIXACL(dir) && !default_acl)
311 mode &= ~current->fs->umask; 308 mode &= ~current->fs->umask;
312 309
313 switch (mode & S_IFMT) { 310 switch (mode & S_IFMT) {
314 case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: 311 case S_IFCHR:
312 case S_IFBLK:
313 case S_IFIFO:
314 case S_IFSOCK:
315 rdev = sysv_encode_dev(rdev); 315 rdev = sysv_encode_dev(rdev);
316 case S_IFREG: 316 case S_IFREG:
317 error = xfs_create(XFS_I(dir), dentry, mode, rdev, &vp, NULL); 317 error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip, NULL);
318 break; 318 break;
319 case S_IFDIR: 319 case S_IFDIR:
320 error = xfs_mkdir(XFS_I(dir), dentry, mode, &vp, NULL); 320 error = xfs_mkdir(XFS_I(dir), &name, mode, &ip, NULL);
321 break; 321 break;
322 default: 322 default:
323 error = EINVAL; 323 error = EINVAL;
324 break; 324 break;
325 } 325 }
326 326
327 if (unlikely(!error)) { 327 if (unlikely(error))
328 error = xfs_init_security(vp, dir); 328 goto out_free_acl;
329 if (error)
330 xfs_cleanup_inode(dir, vp, dentry, mode);
331 }
332 329
333 if (unlikely(default_acl)) { 330 inode = ip->i_vnode;
334 if (!error) { 331
335 error = _ACL_INHERIT(vp, mode, default_acl); 332 error = xfs_init_security(inode, dir);
336 if (!error) 333 if (unlikely(error))
337 xfs_iflags_set(XFS_I(vp), XFS_IMODIFIED); 334 goto out_cleanup_inode;
338 else 335
339 xfs_cleanup_inode(dir, vp, dentry, mode); 336 if (default_acl) {
340 } 337 error = _ACL_INHERIT(inode, mode, default_acl);
338 if (unlikely(error))
339 goto out_cleanup_inode;
340 xfs_iflags_set(ip, XFS_IMODIFIED);
341 _ACL_FREE(default_acl); 341 _ACL_FREE(default_acl);
342 } 342 }
343 343
344 if (likely(!error)) {
345 ASSERT(vp);
346 ip = vn_to_inode(vp);
347 344
348 if (S_ISDIR(mode)) 345 if (S_ISDIR(mode))
349 xfs_validate_fields(ip); 346 xfs_validate_fields(inode);
350 d_instantiate(dentry, ip); 347 d_instantiate(dentry, inode);
351 xfs_validate_fields(dir); 348 xfs_validate_fields(dir);
352 } 349 return -error;
350
351 out_cleanup_inode:
352 xfs_cleanup_inode(dir, inode, dentry, mode);
353 out_free_acl:
354 if (default_acl)
355 _ACL_FREE(default_acl);
353 return -error; 356 return -error;
354} 357}
355 358
@@ -378,13 +381,15 @@ xfs_vn_lookup(
378 struct dentry *dentry, 381 struct dentry *dentry,
379 struct nameidata *nd) 382 struct nameidata *nd)
380{ 383{
381 bhv_vnode_t *cvp; 384 struct xfs_inode *cip;
385 struct xfs_name name;
382 int error; 386 int error;
383 387
384 if (dentry->d_name.len >= MAXNAMELEN) 388 if (dentry->d_name.len >= MAXNAMELEN)
385 return ERR_PTR(-ENAMETOOLONG); 389 return ERR_PTR(-ENAMETOOLONG);
386 390
387 error = xfs_lookup(XFS_I(dir), dentry, &cvp); 391 xfs_dentry_to_name(&name, dentry);
392 error = xfs_lookup(XFS_I(dir), &name, &cip);
388 if (unlikely(error)) { 393 if (unlikely(error)) {
389 if (unlikely(error != ENOENT)) 394 if (unlikely(error != ENOENT))
390 return ERR_PTR(-error); 395 return ERR_PTR(-error);
@@ -392,7 +397,7 @@ xfs_vn_lookup(
392 return NULL; 397 return NULL;
393 } 398 }
394 399
395 return d_splice_alias(vn_to_inode(cvp), dentry); 400 return d_splice_alias(cip->i_vnode, dentry);
396} 401}
397 402
398STATIC int 403STATIC int
@@ -401,23 +406,24 @@ xfs_vn_link(
401 struct inode *dir, 406 struct inode *dir,
402 struct dentry *dentry) 407 struct dentry *dentry)
403{ 408{
404 struct inode *ip; /* inode of guy being linked to */ 409 struct inode *inode; /* inode of guy being linked to */
405 bhv_vnode_t *vp; /* vp of name being linked */ 410 struct xfs_name name;
406 int error; 411 int error;
407 412
408 ip = old_dentry->d_inode; /* inode being linked to */ 413 inode = old_dentry->d_inode;
409 vp = vn_from_inode(ip); 414 xfs_dentry_to_name(&name, dentry);
410 415
411 VN_HOLD(vp); 416 igrab(inode);
412 error = xfs_link(XFS_I(dir), vp, dentry); 417 error = xfs_link(XFS_I(dir), XFS_I(inode), &name);
413 if (unlikely(error)) { 418 if (unlikely(error)) {
414 VN_RELE(vp); 419 iput(inode);
415 } else { 420 return -error;
416 xfs_iflags_set(XFS_I(dir), XFS_IMODIFIED);
417 xfs_validate_fields(ip);
418 d_instantiate(dentry, ip);
419 } 421 }
420 return -error; 422
423 xfs_iflags_set(XFS_I(dir), XFS_IMODIFIED);
424 xfs_validate_fields(inode);
425 d_instantiate(dentry, inode);
426 return 0;
421} 427}
422 428
423STATIC int 429STATIC int
@@ -426,11 +432,13 @@ xfs_vn_unlink(
426 struct dentry *dentry) 432 struct dentry *dentry)
427{ 433{
428 struct inode *inode; 434 struct inode *inode;
435 struct xfs_name name;
429 int error; 436 int error;
430 437
431 inode = dentry->d_inode; 438 inode = dentry->d_inode;
439 xfs_dentry_to_name(&name, dentry);
432 440
433 error = xfs_remove(XFS_I(dir), dentry); 441 error = xfs_remove(XFS_I(dir), &name, XFS_I(inode));
434 if (likely(!error)) { 442 if (likely(!error)) {
435 xfs_validate_fields(dir); /* size needs update */ 443 xfs_validate_fields(dir); /* size needs update */
436 xfs_validate_fields(inode); 444 xfs_validate_fields(inode);
@@ -444,29 +452,34 @@ xfs_vn_symlink(
444 struct dentry *dentry, 452 struct dentry *dentry,
445 const char *symname) 453 const char *symname)
446{ 454{
447 struct inode *ip; 455 struct inode *inode;
448 bhv_vnode_t *cvp; /* used to lookup symlink to put in dentry */ 456 struct xfs_inode *cip = NULL;
457 struct xfs_name name;
449 int error; 458 int error;
450 mode_t mode; 459 mode_t mode;
451 460
452 cvp = NULL;
453
454 mode = S_IFLNK | 461 mode = S_IFLNK |
455 (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO); 462 (irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
463 xfs_dentry_to_name(&name, dentry);
456 464
457 error = xfs_symlink(XFS_I(dir), dentry, (char *)symname, mode, 465 error = xfs_symlink(XFS_I(dir), &name, symname, mode, &cip, NULL);
458 &cvp, NULL); 466 if (unlikely(error))
459 if (likely(!error && cvp)) { 467 goto out;
460 error = xfs_init_security(cvp, dir); 468
461 if (likely(!error)) { 469 inode = cip->i_vnode;
462 ip = vn_to_inode(cvp); 470
463 d_instantiate(dentry, ip); 471 error = xfs_init_security(inode, dir);
464 xfs_validate_fields(dir); 472 if (unlikely(error))
465 xfs_validate_fields(ip); 473 goto out_cleanup_inode;
466 } else { 474
467 xfs_cleanup_inode(dir, cvp, dentry, 0); 475 d_instantiate(dentry, inode);
468 } 476 xfs_validate_fields(dir);
469 } 477 xfs_validate_fields(inode);
478 return 0;
479
480 out_cleanup_inode:
481 xfs_cleanup_inode(dir, inode, dentry, 0);
482 out:
470 return -error; 483 return -error;
471} 484}
472 485
@@ -476,9 +489,12 @@ xfs_vn_rmdir(
476 struct dentry *dentry) 489 struct dentry *dentry)
477{ 490{
478 struct inode *inode = dentry->d_inode; 491 struct inode *inode = dentry->d_inode;
492 struct xfs_name name;
479 int error; 493 int error;
480 494
481 error = xfs_rmdir(XFS_I(dir), dentry); 495 xfs_dentry_to_name(&name, dentry);
496
497 error = xfs_rmdir(XFS_I(dir), &name, XFS_I(inode));
482 if (likely(!error)) { 498 if (likely(!error)) {
483 xfs_validate_fields(inode); 499 xfs_validate_fields(inode);
484 xfs_validate_fields(dir); 500 xfs_validate_fields(dir);
@@ -494,12 +510,15 @@ xfs_vn_rename(
494 struct dentry *ndentry) 510 struct dentry *ndentry)
495{ 511{
496 struct inode *new_inode = ndentry->d_inode; 512 struct inode *new_inode = ndentry->d_inode;
497 bhv_vnode_t *tvp; /* target directory */ 513 struct xfs_name oname;
514 struct xfs_name nname;
498 int error; 515 int error;
499 516
500 tvp = vn_from_inode(ndir); 517 xfs_dentry_to_name(&oname, odentry);
518 xfs_dentry_to_name(&nname, ndentry);
501 519
502 error = xfs_rename(XFS_I(odir), odentry, tvp, ndentry); 520 error = xfs_rename(XFS_I(odir), &oname, XFS_I(odentry->d_inode),
521 XFS_I(ndir), &nname);
503 if (likely(!error)) { 522 if (likely(!error)) {
504 if (new_inode) 523 if (new_inode)
505 xfs_validate_fields(new_inode); 524 xfs_validate_fields(new_inode);
@@ -700,11 +719,19 @@ xfs_vn_setattr(
700 return -error; 719 return -error;
701} 720}
702 721
722/*
723 * block_truncate_page can return an error, but we can't propagate it
724 * at all here. Leave a complaint + stack trace in the syslog because
725 * this could be bad. If it is bad, we need to propagate the error further.
726 */
703STATIC void 727STATIC void
704xfs_vn_truncate( 728xfs_vn_truncate(
705 struct inode *inode) 729 struct inode *inode)
706{ 730{
707 block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_blocks); 731 int error;
732 error = block_truncate_page(inode->i_mapping, inode->i_size,
733 xfs_get_blocks);
734 WARN_ON(error);
708} 735}
709 736
710STATIC int 737STATIC int
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 3ca39c4e5d2a..e5143323e71f 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -99,7 +99,6 @@
99/* 99/*
100 * Feature macros (disable/enable) 100 * Feature macros (disable/enable)
101 */ 101 */
102#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */
103#define HAVE_SPLICE /* a splice(2) exists in 2.6, but not in 2.4 */ 102#define HAVE_SPLICE /* a splice(2) exists in 2.6, but not in 2.4 */
104#ifdef CONFIG_SMP 103#ifdef CONFIG_SMP
105#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */ 104#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 166353388490..21c0dbc74093 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -176,7 +176,6 @@ xfs_read(
176{ 176{
177 struct file *file = iocb->ki_filp; 177 struct file *file = iocb->ki_filp;
178 struct inode *inode = file->f_mapping->host; 178 struct inode *inode = file->f_mapping->host;
179 bhv_vnode_t *vp = XFS_ITOV(ip);
180 xfs_mount_t *mp = ip->i_mount; 179 xfs_mount_t *mp = ip->i_mount;
181 size_t size = 0; 180 size_t size = 0;
182 ssize_t ret = 0; 181 ssize_t ret = 0;
@@ -228,11 +227,11 @@ xfs_read(
228 xfs_ilock(ip, XFS_IOLOCK_SHARED); 227 xfs_ilock(ip, XFS_IOLOCK_SHARED);
229 228
230 if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) { 229 if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) {
231 bhv_vrwlock_t locktype = VRWLOCK_READ;
232 int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags); 230 int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
231 int iolock = XFS_IOLOCK_SHARED;
233 232
234 ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *offset, size, 233 ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, ip, *offset, size,
235 dmflags, &locktype); 234 dmflags, &iolock);
236 if (ret) { 235 if (ret) {
237 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 236 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
238 if (unlikely(ioflags & IO_ISDIRECT)) 237 if (unlikely(ioflags & IO_ISDIRECT))
@@ -242,7 +241,7 @@ xfs_read(
242 } 241 }
243 242
244 if (unlikely(ioflags & IO_ISDIRECT)) { 243 if (unlikely(ioflags & IO_ISDIRECT)) {
245 if (VN_CACHED(vp)) 244 if (inode->i_mapping->nrpages)
246 ret = xfs_flushinval_pages(ip, (*offset & PAGE_CACHE_MASK), 245 ret = xfs_flushinval_pages(ip, (*offset & PAGE_CACHE_MASK),
247 -1, FI_REMAPF_LOCKED); 246 -1, FI_REMAPF_LOCKED);
248 mutex_unlock(&inode->i_mutex); 247 mutex_unlock(&inode->i_mutex);
@@ -276,7 +275,6 @@ xfs_splice_read(
276 int flags, 275 int flags,
277 int ioflags) 276 int ioflags)
278{ 277{
279 bhv_vnode_t *vp = XFS_ITOV(ip);
280 xfs_mount_t *mp = ip->i_mount; 278 xfs_mount_t *mp = ip->i_mount;
281 ssize_t ret; 279 ssize_t ret;
282 280
@@ -287,11 +285,11 @@ xfs_splice_read(
287 xfs_ilock(ip, XFS_IOLOCK_SHARED); 285 xfs_ilock(ip, XFS_IOLOCK_SHARED);
288 286
289 if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) { 287 if (DM_EVENT_ENABLED(ip, DM_EVENT_READ) && !(ioflags & IO_INVIS)) {
290 bhv_vrwlock_t locktype = VRWLOCK_READ; 288 int iolock = XFS_IOLOCK_SHARED;
291 int error; 289 int error;
292 290
293 error = XFS_SEND_DATA(mp, DM_EVENT_READ, vp, *ppos, count, 291 error = XFS_SEND_DATA(mp, DM_EVENT_READ, ip, *ppos, count,
294 FILP_DELAY_FLAG(infilp), &locktype); 292 FILP_DELAY_FLAG(infilp), &iolock);
295 if (error) { 293 if (error) {
296 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 294 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
297 return -error; 295 return -error;
@@ -317,7 +315,6 @@ xfs_splice_write(
317 int flags, 315 int flags,
318 int ioflags) 316 int ioflags)
319{ 317{
320 bhv_vnode_t *vp = XFS_ITOV(ip);
321 xfs_mount_t *mp = ip->i_mount; 318 xfs_mount_t *mp = ip->i_mount;
322 ssize_t ret; 319 ssize_t ret;
323 struct inode *inode = outfilp->f_mapping->host; 320 struct inode *inode = outfilp->f_mapping->host;
@@ -330,11 +327,11 @@ xfs_splice_write(
330 xfs_ilock(ip, XFS_IOLOCK_EXCL); 327 xfs_ilock(ip, XFS_IOLOCK_EXCL);
331 328
332 if (DM_EVENT_ENABLED(ip, DM_EVENT_WRITE) && !(ioflags & IO_INVIS)) { 329 if (DM_EVENT_ENABLED(ip, DM_EVENT_WRITE) && !(ioflags & IO_INVIS)) {
333 bhv_vrwlock_t locktype = VRWLOCK_WRITE; 330 int iolock = XFS_IOLOCK_EXCL;
334 int error; 331 int error;
335 332
336 error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp, *ppos, count, 333 error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, ip, *ppos, count,
337 FILP_DELAY_FLAG(outfilp), &locktype); 334 FILP_DELAY_FLAG(outfilp), &iolock);
338 if (error) { 335 if (error) {
339 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 336 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
340 return -error; 337 return -error;
@@ -573,14 +570,12 @@ xfs_write(
573 struct file *file = iocb->ki_filp; 570 struct file *file = iocb->ki_filp;
574 struct address_space *mapping = file->f_mapping; 571 struct address_space *mapping = file->f_mapping;
575 struct inode *inode = mapping->host; 572 struct inode *inode = mapping->host;
576 bhv_vnode_t *vp = XFS_ITOV(xip);
577 unsigned long segs = nsegs; 573 unsigned long segs = nsegs;
578 xfs_mount_t *mp; 574 xfs_mount_t *mp;
579 ssize_t ret = 0, error = 0; 575 ssize_t ret = 0, error = 0;
580 xfs_fsize_t isize, new_size; 576 xfs_fsize_t isize, new_size;
581 int iolock; 577 int iolock;
582 int eventsent = 0; 578 int eventsent = 0;
583 bhv_vrwlock_t locktype;
584 size_t ocount = 0, count; 579 size_t ocount = 0, count;
585 loff_t pos; 580 loff_t pos;
586 int need_i_mutex; 581 int need_i_mutex;
@@ -607,11 +602,9 @@ xfs_write(
607relock: 602relock:
608 if (ioflags & IO_ISDIRECT) { 603 if (ioflags & IO_ISDIRECT) {
609 iolock = XFS_IOLOCK_SHARED; 604 iolock = XFS_IOLOCK_SHARED;
610 locktype = VRWLOCK_WRITE_DIRECT;
611 need_i_mutex = 0; 605 need_i_mutex = 0;
612 } else { 606 } else {
613 iolock = XFS_IOLOCK_EXCL; 607 iolock = XFS_IOLOCK_EXCL;
614 locktype = VRWLOCK_WRITE;
615 need_i_mutex = 1; 608 need_i_mutex = 1;
616 mutex_lock(&inode->i_mutex); 609 mutex_lock(&inode->i_mutex);
617 } 610 }
@@ -634,9 +627,8 @@ start:
634 dmflags |= DM_FLAGS_IMUX; 627 dmflags |= DM_FLAGS_IMUX;
635 628
636 xfs_iunlock(xip, XFS_ILOCK_EXCL); 629 xfs_iunlock(xip, XFS_ILOCK_EXCL);
637 error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp, 630 error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, xip,
638 pos, count, 631 pos, count, dmflags, &iolock);
639 dmflags, &locktype);
640 if (error) { 632 if (error) {
641 goto out_unlock_internal; 633 goto out_unlock_internal;
642 } 634 }
@@ -664,10 +656,9 @@ start:
664 return XFS_ERROR(-EINVAL); 656 return XFS_ERROR(-EINVAL);
665 } 657 }
666 658
667 if (!need_i_mutex && (VN_CACHED(vp) || pos > xip->i_size)) { 659 if (!need_i_mutex && (mapping->nrpages || pos > xip->i_size)) {
668 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock); 660 xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
669 iolock = XFS_IOLOCK_EXCL; 661 iolock = XFS_IOLOCK_EXCL;
670 locktype = VRWLOCK_WRITE;
671 need_i_mutex = 1; 662 need_i_mutex = 1;
672 mutex_lock(&inode->i_mutex); 663 mutex_lock(&inode->i_mutex);
673 xfs_ilock(xip, XFS_ILOCK_EXCL|iolock); 664 xfs_ilock(xip, XFS_ILOCK_EXCL|iolock);
@@ -727,7 +718,7 @@ retry:
727 current->backing_dev_info = mapping->backing_dev_info; 718 current->backing_dev_info = mapping->backing_dev_info;
728 719
729 if ((ioflags & IO_ISDIRECT)) { 720 if ((ioflags & IO_ISDIRECT)) {
730 if (VN_CACHED(vp)) { 721 if (mapping->nrpages) {
731 WARN_ON(need_i_mutex == 0); 722 WARN_ON(need_i_mutex == 0);
732 xfs_inval_cached_trace(xip, pos, -1, 723 xfs_inval_cached_trace(xip, pos, -1,
733 (pos & PAGE_CACHE_MASK), -1); 724 (pos & PAGE_CACHE_MASK), -1);
@@ -744,7 +735,6 @@ retry:
744 mutex_unlock(&inode->i_mutex); 735 mutex_unlock(&inode->i_mutex);
745 736
746 iolock = XFS_IOLOCK_SHARED; 737 iolock = XFS_IOLOCK_SHARED;
747 locktype = VRWLOCK_WRITE_DIRECT;
748 need_i_mutex = 0; 738 need_i_mutex = 0;
749 } 739 }
750 740
@@ -781,15 +771,15 @@ retry:
781 771
782 if (ret == -ENOSPC && 772 if (ret == -ENOSPC &&
783 DM_EVENT_ENABLED(xip, DM_EVENT_NOSPACE) && !(ioflags & IO_INVIS)) { 773 DM_EVENT_ENABLED(xip, DM_EVENT_NOSPACE) && !(ioflags & IO_INVIS)) {
784 xfs_rwunlock(xip, locktype); 774 xfs_iunlock(xip, iolock);
785 if (need_i_mutex) 775 if (need_i_mutex)
786 mutex_unlock(&inode->i_mutex); 776 mutex_unlock(&inode->i_mutex);
787 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, 777 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, xip,
788 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL, 778 DM_RIGHT_NULL, xip, DM_RIGHT_NULL, NULL, NULL,
789 0, 0, 0); /* Delay flag intentionally unused */ 779 0, 0, 0); /* Delay flag intentionally unused */
790 if (need_i_mutex) 780 if (need_i_mutex)
791 mutex_lock(&inode->i_mutex); 781 mutex_lock(&inode->i_mutex);
792 xfs_rwlock(xip, locktype); 782 xfs_ilock(xip, iolock);
793 if (error) 783 if (error)
794 goto out_unlock_internal; 784 goto out_unlock_internal;
795 pos = xip->i_size; 785 pos = xip->i_size;
@@ -817,7 +807,8 @@ retry:
817 /* Handle various SYNC-type writes */ 807 /* Handle various SYNC-type writes */
818 if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { 808 if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {
819 int error2; 809 int error2;
820 xfs_rwunlock(xip, locktype); 810
811 xfs_iunlock(xip, iolock);
821 if (need_i_mutex) 812 if (need_i_mutex)
822 mutex_unlock(&inode->i_mutex); 813 mutex_unlock(&inode->i_mutex);
823 error2 = sync_page_range(inode, mapping, pos, ret); 814 error2 = sync_page_range(inode, mapping, pos, ret);
@@ -825,7 +816,7 @@ retry:
825 error = error2; 816 error = error2;
826 if (need_i_mutex) 817 if (need_i_mutex)
827 mutex_lock(&inode->i_mutex); 818 mutex_lock(&inode->i_mutex);
828 xfs_rwlock(xip, locktype); 819 xfs_ilock(xip, iolock);
829 error2 = xfs_write_sync_logforce(mp, xip); 820 error2 = xfs_write_sync_logforce(mp, xip);
830 if (!error) 821 if (!error)
831 error = error2; 822 error = error2;
@@ -846,7 +837,7 @@ retry:
846 xip->i_d.di_size = xip->i_size; 837 xip->i_d.di_size = xip->i_size;
847 xfs_iunlock(xip, XFS_ILOCK_EXCL); 838 xfs_iunlock(xip, XFS_ILOCK_EXCL);
848 } 839 }
849 xfs_rwunlock(xip, locktype); 840 xfs_iunlock(xip, iolock);
850 out_unlock_mutex: 841 out_unlock_mutex:
851 if (need_i_mutex) 842 if (need_i_mutex)
852 mutex_unlock(&inode->i_mutex); 843 mutex_unlock(&inode->i_mutex);
@@ -884,28 +875,23 @@ xfs_bdstrat_cb(struct xfs_buf *bp)
884} 875}
885 876
886/* 877/*
887 * Wrapper around bdstrat so that we can stop data 878 * Wrapper around bdstrat so that we can stop data from going to disk in case
888 * from going to disk in case we are shutting down the filesystem. 879 * we are shutting down the filesystem. Typically user data goes thru this
889 * Typically user data goes thru this path; one of the exceptions 880 * path; one of the exceptions is the superblock.
890 * is the superblock.
891 */ 881 */
892int 882void
893xfsbdstrat( 883xfsbdstrat(
894 struct xfs_mount *mp, 884 struct xfs_mount *mp,
895 struct xfs_buf *bp) 885 struct xfs_buf *bp)
896{ 886{
897 ASSERT(mp); 887 ASSERT(mp);
898 if (!XFS_FORCED_SHUTDOWN(mp)) { 888 if (!XFS_FORCED_SHUTDOWN(mp)) {
899 /* Grio redirection would go here
900 * if (XFS_BUF_IS_GRIO(bp)) {
901 */
902
903 xfs_buf_iorequest(bp); 889 xfs_buf_iorequest(bp);
904 return 0; 890 return;
905 } 891 }
906 892
907 xfs_buftrace("XFSBDSTRAT IOERROR", bp); 893 xfs_buftrace("XFSBDSTRAT IOERROR", bp);
908 return (xfs_bioerror_relse(bp)); 894 xfs_bioerror_relse(bp);
909} 895}
910 896
911/* 897/*
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h
index e200253139cf..e1d498b4ba7a 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.h
+++ b/fs/xfs/linux-2.6/xfs_lrw.h
@@ -68,7 +68,8 @@ extern void xfs_inval_cached_trace(struct xfs_inode *,
68#define xfs_inval_cached_trace(ip, offset, len, first, last) 68#define xfs_inval_cached_trace(ip, offset, len, first, last)
69#endif 69#endif
70 70
71extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *); 71/* errors from xfsbdstrat() must be extracted from the buffer */
72extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
72extern int xfs_bdstrat_cb(struct xfs_buf *); 73extern int xfs_bdstrat_cb(struct xfs_buf *);
73extern int xfs_dev_is_read_only(struct xfs_mount *, char *); 74extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
74 75
diff --git a/fs/xfs/linux-2.6/xfs_stats.h b/fs/xfs/linux-2.6/xfs_stats.h
index 8ba7a2fa6c1d..afd0b0d5fdb2 100644
--- a/fs/xfs/linux-2.6/xfs_stats.h
+++ b/fs/xfs/linux-2.6/xfs_stats.h
@@ -144,8 +144,8 @@ extern void xfs_cleanup_procfs(void);
144# define XFS_STATS_DEC(count) 144# define XFS_STATS_DEC(count)
145# define XFS_STATS_ADD(count, inc) 145# define XFS_STATS_ADD(count, inc)
146 146
147static __inline void xfs_init_procfs(void) { }; 147static inline void xfs_init_procfs(void) { };
148static __inline void xfs_cleanup_procfs(void) { }; 148static inline void xfs_cleanup_procfs(void) { };
149 149
150#endif /* !CONFIG_PROC_FS */ 150#endif /* !CONFIG_PROC_FS */
151 151
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 8831d9518790..865eb708aa95 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -896,7 +896,8 @@ xfs_fs_write_inode(
896 struct inode *inode, 896 struct inode *inode,
897 int sync) 897 int sync)
898{ 898{
899 int error = 0, flags = FLUSH_INODE; 899 int error = 0;
900 int flags = 0;
900 901
901 xfs_itrace_entry(XFS_I(inode)); 902 xfs_itrace_entry(XFS_I(inode));
902 if (sync) { 903 if (sync) {
@@ -934,7 +935,7 @@ xfs_fs_clear_inode(
934 xfs_inactive(ip); 935 xfs_inactive(ip);
935 xfs_iflags_clear(ip, XFS_IMODIFIED); 936 xfs_iflags_clear(ip, XFS_IMODIFIED);
936 if (xfs_reclaim(ip)) 937 if (xfs_reclaim(ip))
937 panic("%s: cannot reclaim 0x%p\n", __FUNCTION__, inode); 938 panic("%s: cannot reclaim 0x%p\n", __func__, inode);
938 } 939 }
939 940
940 ASSERT(XFS_I(inode) == NULL); 941 ASSERT(XFS_I(inode) == NULL);
@@ -1027,8 +1028,7 @@ xfs_sync_worker(
1027 int error; 1028 int error;
1028 1029
1029 if (!(mp->m_flags & XFS_MOUNT_RDONLY)) 1030 if (!(mp->m_flags & XFS_MOUNT_RDONLY))
1030 error = xfs_sync(mp, SYNC_FSDATA | SYNC_BDFLUSH | SYNC_ATTR | 1031 error = xfs_sync(mp, SYNC_FSDATA | SYNC_BDFLUSH | SYNC_ATTR);
1031 SYNC_REFCACHE | SYNC_SUPER);
1032 mp->m_sync_seq++; 1032 mp->m_sync_seq++;
1033 wake_up(&mp->m_wait_single_sync_task); 1033 wake_up(&mp->m_wait_single_sync_task);
1034} 1034}
@@ -1306,7 +1306,7 @@ xfs_fs_fill_super(
1306 void *data, 1306 void *data,
1307 int silent) 1307 int silent)
1308{ 1308{
1309 struct inode *rootvp; 1309 struct inode *root;
1310 struct xfs_mount *mp = NULL; 1310 struct xfs_mount *mp = NULL;
1311 struct xfs_mount_args *args = xfs_args_allocate(sb, silent); 1311 struct xfs_mount_args *args = xfs_args_allocate(sb, silent);
1312 int error; 1312 int error;
@@ -1344,19 +1344,18 @@ xfs_fs_fill_super(
1344 sb->s_time_gran = 1; 1344 sb->s_time_gran = 1;
1345 set_posix_acl_flag(sb); 1345 set_posix_acl_flag(sb);
1346 1346
1347 rootvp = igrab(mp->m_rootip->i_vnode); 1347 root = igrab(mp->m_rootip->i_vnode);
1348 if (!rootvp) { 1348 if (!root) {
1349 error = ENOENT; 1349 error = ENOENT;
1350 goto fail_unmount; 1350 goto fail_unmount;
1351 } 1351 }
1352 1352 if (is_bad_inode(root)) {
1353 sb->s_root = d_alloc_root(vn_to_inode(rootvp)); 1353 error = EINVAL;
1354 if (!sb->s_root) {
1355 error = ENOMEM;
1356 goto fail_vnrele; 1354 goto fail_vnrele;
1357 } 1355 }
1358 if (is_bad_inode(sb->s_root->d_inode)) { 1356 sb->s_root = d_alloc_root(root);
1359 error = EINVAL; 1357 if (!sb->s_root) {
1358 error = ENOMEM;
1360 goto fail_vnrele; 1359 goto fail_vnrele;
1361 } 1360 }
1362 1361
@@ -1378,7 +1377,7 @@ fail_vnrele:
1378 dput(sb->s_root); 1377 dput(sb->s_root);
1379 sb->s_root = NULL; 1378 sb->s_root = NULL;
1380 } else { 1379 } else {
1381 VN_RELE(rootvp); 1380 iput(root);
1382 } 1381 }
1383 1382
1384fail_unmount: 1383fail_unmount:
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h
index 3efcf45b14ab..3efb7c6d3303 100644
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/linux-2.6/xfs_super.h
@@ -50,13 +50,7 @@ extern void xfs_qm_exit(void);
50# define set_posix_acl_flag(sb) do { } while (0) 50# define set_posix_acl_flag(sb) do { } while (0)
51#endif 51#endif
52 52
53#ifdef CONFIG_XFS_SECURITY 53#define XFS_SECURITY_STRING "security attributes, "
54# define XFS_SECURITY_STRING "security attributes, "
55# define ENOSECURITY 0
56#else
57# define XFS_SECURITY_STRING
58# define ENOSECURITY EOPNOTSUPP
59#endif
60 54
61#ifdef CONFIG_XFS_RT 55#ifdef CONFIG_XFS_RT
62# define XFS_REALTIME_STRING "realtime, " 56# define XFS_REALTIME_STRING "realtime, "
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index 4da03a4e3520..7e60c7776b1c 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -49,7 +49,6 @@ typedef struct bhv_vfs_sync_work {
49#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */ 49#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
50#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */ 50#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
51#define SYNC_IOWAIT 0x0100 /* wait for all I/O to complete */ 51#define SYNC_IOWAIT 0x0100 /* wait for all I/O to complete */
52#define SYNC_SUPER 0x0200 /* flush superblock to disk */
53 52
54/* 53/*
55 * When remounting a filesystem read-only or freezing the filesystem, 54 * When remounting a filesystem read-only or freezing the filesystem,
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index b5ea418693b1..8b4d63ce8694 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -23,8 +23,6 @@ struct bhv_vattr;
23struct xfs_iomap; 23struct xfs_iomap;
24struct attrlist_cursor_kern; 24struct attrlist_cursor_kern;
25 25
26typedef struct dentry bhv_vname_t;
27typedef __u64 bhv_vnumber_t;
28typedef struct inode bhv_vnode_t; 26typedef struct inode bhv_vnode_t;
29 27
30#define VN_ISLNK(vp) S_ISLNK((vp)->i_mode) 28#define VN_ISLNK(vp) S_ISLNK((vp)->i_mode)
@@ -46,18 +44,6 @@ static inline struct inode *vn_to_inode(bhv_vnode_t *vnode)
46} 44}
47 45
48/* 46/*
49 * Values for the vop_rwlock/rwunlock flags parameter.
50 */
51typedef enum bhv_vrwlock {
52 VRWLOCK_NONE,
53 VRWLOCK_READ,
54 VRWLOCK_WRITE,
55 VRWLOCK_WRITE_DIRECT,
56 VRWLOCK_TRY_READ,
57 VRWLOCK_TRY_WRITE
58} bhv_vrwlock_t;
59
60/*
61 * Return values for xfs_inactive. A return value of 47 * Return values for xfs_inactive. A return value of
62 * VN_INACTIVE_NOCACHE implies that the file system behavior 48 * VN_INACTIVE_NOCACHE implies that the file system behavior
63 * has disassociated its state and bhv_desc_t from the vnode. 49 * has disassociated its state and bhv_desc_t from the vnode.
@@ -73,12 +59,9 @@ typedef enum bhv_vrwlock {
73#define IO_INVIS 0x00020 /* don't update inode timestamps */ 59#define IO_INVIS 0x00020 /* don't update inode timestamps */
74 60
75/* 61/*
76 * Flags for vop_iflush call 62 * Flags for xfs_inode_flush
77 */ 63 */
78#define FLUSH_SYNC 1 /* wait for flush to complete */ 64#define FLUSH_SYNC 1 /* wait for flush to complete */
79#define FLUSH_INODE 2 /* flush the inode itself */
80#define FLUSH_LOG 4 /* force the last log entry for
81 * this inode out to disk */
82 65
83/* 66/*
84 * Flush/Invalidate options for vop_toss/flush/flushinval_pages. 67 * Flush/Invalidate options for vop_toss/flush/flushinval_pages.
@@ -226,13 +209,6 @@ static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp)
226} 209}
227 210
228/* 211/*
229 * Vname handling macros.
230 */
231#define VNAME(dentry) ((char *) (dentry)->d_name.name)
232#define VNAMELEN(dentry) ((dentry)->d_name.len)
233#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
234
235/*
236 * Dealing with bad inodes 212 * Dealing with bad inodes
237 */ 213 */
238static inline int VN_BAD(bhv_vnode_t *vp) 214static inline int VN_BAD(bhv_vnode_t *vp)
@@ -303,9 +279,9 @@ extern void xfs_itrace_hold(struct xfs_inode *, char *, int, inst_t *);
303extern void _xfs_itrace_ref(struct xfs_inode *, char *, int, inst_t *); 279extern void _xfs_itrace_ref(struct xfs_inode *, char *, int, inst_t *);
304extern void xfs_itrace_rele(struct xfs_inode *, char *, int, inst_t *); 280extern void xfs_itrace_rele(struct xfs_inode *, char *, int, inst_t *);
305#define xfs_itrace_entry(ip) \ 281#define xfs_itrace_entry(ip) \
306 _xfs_itrace_entry(ip, __FUNCTION__, (inst_t *)__return_address) 282 _xfs_itrace_entry(ip, __func__, (inst_t *)__return_address)
307#define xfs_itrace_exit(ip) \ 283#define xfs_itrace_exit(ip) \
308 _xfs_itrace_exit(ip, __FUNCTION__, (inst_t *)__return_address) 284 _xfs_itrace_exit(ip, __func__, (inst_t *)__return_address)
309#define xfs_itrace_exit_tag(ip, tag) \ 285#define xfs_itrace_exit_tag(ip, tag) \
310 _xfs_itrace_exit(ip, tag, (inst_t *)__return_address) 286 _xfs_itrace_exit(ip, tag, (inst_t *)__return_address)
311#define xfs_itrace_ref(ip) \ 287#define xfs_itrace_ref(ip) \