]> err.no Git - linux-2.6/blobdiff - fs/xfs/linux-2.6/xfs_vnode.c
Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-2.6] / fs / xfs / linux-2.6 / xfs_vnode.c
index d27c25b27ccd4aec1e4f8c8d235e7f41b07034dd..814169fd7e1e2088fbc956cada3f432ed3da31bb 100644 (file)
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
+#include "xfs_vnodeops.h"
+#include "xfs_bmap_btree.h"
+#include "xfs_inode.h"
+
+/*
+ * And this gunk is needed for xfs_mount.h"
+ */
+#include "xfs_log.h"
+#include "xfs_trans.h"
+#include "xfs_sb.h"
+#include "xfs_dmapi.h"
+#include "xfs_inum.h"
+#include "xfs_ag.h"
+#include "xfs_mount.h"
 
-uint64_t vn_generation;                /* vnode generation number */
-DEFINE_SPINLOCK(vnumber_lock);
 
 /*
  * Dedicated vnode inactive/reclaim sync semaphores.
@@ -26,7 +38,7 @@ DEFINE_SPINLOCK(vnumber_lock);
  */
 #define NVSYNC                  37
 #define vptosync(v)             (&vsync[((unsigned long)v) % NVSYNC])
-STATIC wait_queue_head_t vsync[NVSYNC];
+static wait_queue_head_t vsync[NVSYNC];
 
 void
 vn_init(void)
@@ -39,51 +51,48 @@ vn_init(void)
 
 void
 vn_iowait(
-       struct vnode    *vp)
+       xfs_inode_t     *ip)
 {
-       wait_queue_head_t *wq = vptosync(vp);
+       wait_queue_head_t *wq = vptosync(ip);
 
-       wait_event(*wq, (atomic_read(&vp->v_iocount) == 0));
+       wait_event(*wq, (atomic_read(&ip->i_iocount) == 0));
 }
 
 void
 vn_iowake(
-       struct vnode    *vp)
+       xfs_inode_t     *ip)
 {
-       if (atomic_dec_and_test(&vp->v_iocount))
-               wake_up(vptosync(vp));
+       if (atomic_dec_and_test(&ip->i_iocount))
+               wake_up(vptosync(ip));
 }
 
-struct vnode *
+/*
+ * Volume managers supporting multiple paths can send back ENODEV when the
+ * final path disappears.  In this case continuing to fill the page cache
+ * with dirty data which cannot be written out is evil, so prevent that.
+ */
+void
+vn_ioerror(
+       xfs_inode_t     *ip,
+       int             error,
+       char            *f,
+       int             l)
+{
+       if (unlikely(error == -ENODEV))
+               xfs_do_force_shutdown(ip->i_mount, SHUTDOWN_DEVICE_REQ, f, l);
+}
+
+bhv_vnode_t *
 vn_initialize(
        struct inode    *inode)
 {
-       struct vnode    *vp = vn_from_inode(inode);
+       bhv_vnode_t     *vp = vn_from_inode(inode);
 
        XFS_STATS_INC(vn_active);
        XFS_STATS_INC(vn_alloc);
 
-       vp->v_flag = VMODIFIED;
-       spinlock_init(&vp->v_lock, "v_lock");
-
-       spin_lock(&vnumber_lock);
-       if (!++vn_generation)   /* v_number shouldn't be zero */
-               vn_generation++;
-       vp->v_number = vn_generation;
-       spin_unlock(&vnumber_lock);
-
        ASSERT(VN_CACHED(vp) == 0);
 
-       /* Initialize the first behavior and the behavior chain head. */
-       vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
-
-       atomic_set(&vp->v_iocount, 0);
-
-#ifdef XFS_VNODE_TRACE
-       vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
-#endif /* XFS_VNODE_TRACE */
-
-       vn_trace_exit(vp, __FUNCTION__, (inst_t *)__return_address);
        return vp;
 }
 
@@ -94,8 +103,8 @@ vn_initialize(
  */
 void
 vn_revalidate_core(
-       struct vnode    *vp,
-       vattr_t         *vap)
+       bhv_vnode_t     *vp,
+       bhv_vattr_t     *vap)
 {
        struct inode    *inode = vn_to_inode(vp);
 
@@ -106,7 +115,6 @@ vn_revalidate_core(
        inode->i_blocks     = vap->va_nblocks;
        inode->i_mtime      = vap->va_mtime;
        inode->i_ctime      = vap->va_ctime;
-       inode->i_blksize    = vap->va_blocksize;
        if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
                inode->i_flags |= S_IMMUTABLE;
        else
@@ -130,26 +138,26 @@ vn_revalidate_core(
  */
 int
 __vn_revalidate(
-       struct vnode    *vp,
-       struct vattr    *vattr)
+       bhv_vnode_t     *vp,
+       bhv_vattr_t     *vattr)
 {
        int             error;
 
-       vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
+       vn_trace_entry(xfs_vtoi(vp), __FUNCTION__, (inst_t *)__return_address);
        vattr->va_mask = XFS_AT_STAT | XFS_AT_XFLAGS;
-       VOP_GETATTR(vp, vattr, 0, NULL, error);
+       error = xfs_getattr(xfs_vtoi(vp), vattr, 0);
        if (likely(!error)) {
                vn_revalidate_core(vp, vattr);
-               VUNMODIFY(vp);
+               xfs_iflags_clear(xfs_vtoi(vp), XFS_IMODIFIED);
        }
        return -error;
 }
 
 int
 vn_revalidate(
-       struct vnode    *vp)
+       bhv_vnode_t     *vp)
 {
-       vattr_t         vattr;
+       bhv_vattr_t     vattr;
 
        return __vn_revalidate(vp, &vattr);
 }
@@ -157,32 +165,43 @@ vn_revalidate(
 /*
  * Add a reference to a referenced vnode.
  */
-struct vnode *
+bhv_vnode_t *
 vn_hold(
-       struct vnode    *vp)
+       bhv_vnode_t     *vp)
 {
        struct inode    *inode;
 
        XFS_STATS_INC(vn_hold);
 
-       VN_LOCK(vp);
        inode = igrab(vn_to_inode(vp));
        ASSERT(inode);
-       VN_UNLOCK(vp, 0);
 
        return vp;
 }
 
 #ifdef XFS_VNODE_TRACE
 
-#define KTRACE_ENTER(vp, vk, s, line, ra)                      \
-       ktrace_enter(   (vp)->v_trace,                          \
+/*
+ * Reference count of Linux inode if present, -1 if the xfs_inode
+ * has no associated Linux inode.
+ */
+static inline int xfs_icount(struct xfs_inode *ip)
+{
+       bhv_vnode_t *vp = XFS_ITOV_NULL(ip);
+
+       if (vp)
+               return vn_count(vp);
+       return -1;
+}
+
+#define KTRACE_ENTER(ip, vk, s, line, ra)                      \
+       ktrace_enter(   (ip)->i_trace,                          \
 /*  0 */               (void *)(__psint_t)(vk),                \
 /*  1 */               (void *)(s),                            \
 /*  2 */               (void *)(__psint_t) line,               \
-/*  3 */               (void *)(__psint_t)(vn_count(vp)),      \
+/*  3 */               (void *)(__psint_t)xfs_icount(ip),      \
 /*  4 */               (void *)(ra),                           \
-/*  5 */               (void *)(__psunsigned_t)(vp)->v_flag,   \
+/*  5 */               NULL,                                   \
 /*  6 */               (void *)(__psint_t)current_cpu(),       \
 /*  7 */               (void *)(__psint_t)current_pid(),       \
 /*  8 */               (void *)__return_address,               \
@@ -192,32 +211,32 @@ vn_hold(
  * Vnode tracing code.
  */
 void
-vn_trace_entry(vnode_t *vp, const char *func, inst_t *ra)
+vn_trace_entry(xfs_inode_t *ip, const char *func, inst_t *ra)
 {
-       KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra);
+       KTRACE_ENTER(ip, VNODE_KTRACE_ENTRY, func, 0, ra);
 }
 
 void
-vn_trace_exit(vnode_t *vp, const char *func, inst_t *ra)
+vn_trace_exit(xfs_inode_t *ip, const char *func, inst_t *ra)
 {
-       KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra);
+       KTRACE_ENTER(ip, VNODE_KTRACE_EXIT, func, 0, ra);
 }
 
 void
-vn_trace_hold(vnode_t *vp, char *file, int line, inst_t *ra)
+vn_trace_hold(xfs_inode_t *ip, char *file, int line, inst_t *ra)
 {
-       KTRACE_ENTER(vp, VNODE_KTRACE_HOLD, file, line, ra);
+       KTRACE_ENTER(ip, VNODE_KTRACE_HOLD, file, line, ra);
 }
 
 void
-vn_trace_ref(vnode_t *vp, char *file, int line, inst_t *ra)
+vn_trace_ref(xfs_inode_t *ip, char *file, int line, inst_t *ra)
 {
-       KTRACE_ENTER(vp, VNODE_KTRACE_REF, file, line, ra);
+       KTRACE_ENTER(ip, VNODE_KTRACE_REF, file, line, ra);
 }
 
 void
-vn_trace_rele(vnode_t *vp, char *file, int line, inst_t *ra)
+vn_trace_rele(xfs_inode_t *ip, char *file, int line, inst_t *ra)
 {
-       KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
+       KTRACE_ENTER(ip, VNODE_KTRACE_RELE, file, line, ra);
 }
 #endif /* XFS_VNODE_TRACE */