Whamcloud - gitweb
LU-2158 fsfilt: Remove bits from fsfilt_ext3.c/lustre_fsfilt.h
[fs/lustre-release.git] / lustre / include / linux / lustre_fsfilt.h
index 37ffc4f..94fc528 100644 (file)
@@ -1,68 +1,74 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
+/*
+ * GPL HEADER START
  *
- *  Copyright (C) 2001 Cluster File Systems, Inc. <info@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is part of Lustre, http://www.lustre.org.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   Lustre is free software; you can redistribute it and/or
- *   modify it under the terms of version 2 of the GNU General Public
- *   License as published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   Lustre is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
- *   You should have received a copy of the GNU General Public License
- *   along with Lustre; if not, write to the Free Software
- *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
  *
- * Filesystem interface helper.
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/include/linux/lustre_fsfilt.h
  *
+ * Filesystem interface helper.
  */
 
+#ifndef _LINUX_LUSTRE_FSFILT_H
+#define _LINUX_LUSTRE_FSFILT_H
+
 #ifndef _LUSTRE_FSFILT_H
-#define _LUSTRE_FSFILT_H
+#error Do not #include this file directly. #include <lustre_fsfilt.h> instead
+#endif
 
 #ifdef __KERNEL__
 
-#include <linux/obd.h>
-#include <linux/fs.h>
+#include <obd.h>
+#include <obd_class.h>
 
 typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd,
                             void *data, int error);
 
-struct fsfilt_objinfo {
-        struct dentry *fso_dentry;
-        int fso_bufcnt;
-};
-
 struct fsfilt_operations {
-        struct list_head fs_list;
-        struct module *fs_owner;
+        cfs_list_t fs_list;
+        cfs_module_t *fs_owner;
         char   *fs_type;
-        void   *(* fs_start)(struct inode *inode, int op, void *desc_private);
-        void   *(* fs_brw_start)(int objcount, struct fsfilt_objinfo *fso,
-                                 int niocount, void *desc_private);
+        char   *(* fs_getlabel)(struct super_block *sb);
+        void   *(* fs_start)(struct inode *inode, int op, void *desc_private,
+                             int logs);
         int     (* fs_commit)(struct inode *inode, void *handle,int force_sync);
-        int     (* fs_setattr)(struct dentry *dentry, void *handle,
-                               struct iattr *iattr, int do_trunc);
-        int     (* fs_set_md)(struct inode *inode, void *handle, void *md,
-                              int size);
-        int     (* fs_get_md)(struct inode *inode, void *md, int size);
-        ssize_t (* fs_readpage)(struct file *file, char *buf, size_t count,
-                                loff_t *offset);
-        int     (* fs_journal_data)(struct file *file);
-        int     (* fs_set_last_rcvd)(struct obd_device *obd, __u64 last_rcvd,
-                                     void *handle, fsfilt_cb_t cb_func,
-                                     void *cb_data);
-        int     (* fs_statfs)(struct super_block *sb, struct obd_statfs *osfs);
-        int     (* fs_sync)(struct super_block *sb);
-        int     (* fs_prep_san_write)(struct inode *inode, long *blocks,
-                                      int nblocks, loff_t newsize);
-        int     (* fs_write_record)(struct file *, char *, int size, loff_t *);
-        int     (* fs_read_record)(struct file *, char *, int size, loff_t *);
+        int     (* fs_map_inode_pages)(struct inode *inode, struct page **page,
+                                       int pages, unsigned long *blocks,
+                                       int *created, int create,
+                                      struct mutex *sem);
+        int     (* fs_write_record)(struct file *, void *, int size, loff_t *,
+                                    int force_sync);
+        int     (* fs_read_record)(struct file *, void *, int size, loff_t *);
+        int     (* fs_setup)(struct super_block *sb);
 };
 
 extern int fsfilt_register_ops(struct fsfilt_operations *fs_ops);
@@ -70,63 +76,70 @@ extern void fsfilt_unregister_ops(struct fsfilt_operations *fs_ops);
 extern struct fsfilt_operations *fsfilt_get_ops(const char *type);
 extern void fsfilt_put_ops(struct fsfilt_operations *fs_ops);
 
-#define FSFILT_OP_UNLINK         1
-#define FSFILT_OP_RMDIR          2
-#define FSFILT_OP_RENAME         3
-#define FSFILT_OP_CREATE         4
-#define FSFILT_OP_MKDIR          5
-#define FSFILT_OP_SYMLINK        6
-#define FSFILT_OP_MKNOD          7
-#define FSFILT_OP_SETATTR        8
-#define FSFILT_OP_LINK           9
-#define FSFILT_OP_CREATE_LOG    10
-#define FSFILT_OP_UNLINK_LOG    11
-
-static inline void *fsfilt_start(struct obd_device *obd, struct inode *inode,
-                                 int op, struct obd_trans_info *oti)
+static inline char *fsfilt_get_label(struct obd_device *obd,
+                                     struct super_block *sb)
 {
-        unsigned long now = jiffies;
-        void *parent_handle = oti ? oti->oti_handle : NULL;
-        void *handle = obd->obd_fsops->fs_start(inode, op, parent_handle);
-        CDEBUG(D_HA, "started handle %p (%p)\n", handle, parent_handle);
+        if (obd->obd_fsops->fs_getlabel == NULL)
+                return NULL;
+        if (obd->obd_fsops->fs_getlabel(sb)[0] == '\0')
+                return NULL;
 
-        if (oti != NULL) {
-                if (parent_handle == NULL) {
-                        oti->oti_handle = handle;
-                } else if (handle != parent_handle) {
-                        CERROR("mismatch: parent %p, handle %p, oti %p\n",
-                               parent_handle, handle, oti->oti_handle);
-                        LBUG();
-                }
-        }
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
-        return handle;
+        return obd->obd_fsops->fs_getlabel(sb);
 }
 
-static inline void *fsfilt_brw_start(struct obd_device *obd, int objcount,
-                                     struct fsfilt_objinfo *fso, int niocount,
-                                     struct obd_trans_info *oti)
+#define FSFILT_OP_UNLINK                1
+#define FSFILT_OP_RMDIR                 2
+#define FSFILT_OP_RENAME                3
+#define FSFILT_OP_CREATE                4
+#define FSFILT_OP_MKDIR                 5
+#define FSFILT_OP_SYMLINK               6
+#define FSFILT_OP_MKNOD                 7
+#define FSFILT_OP_SETATTR               8
+#define FSFILT_OP_LINK                  9
+#define FSFILT_OP_CANCEL_UNLINK         10
+
+#define __fsfilt_check_slow(obd, start, msg)                              \
+do {                                                                      \
+        if (cfs_time_before(jiffies, start + 15 * CFS_HZ))                \
+                break;                                                    \
+        else if (cfs_time_before(jiffies, start + 30 * CFS_HZ))           \
+                CDEBUG(D_VFSTRACE, "%s: slow %s %lus\n", obd->obd_name,   \
+                       msg, (jiffies-start) / CFS_HZ);                    \
+        else if (cfs_time_before(jiffies, start + DISK_TIMEOUT * CFS_HZ)) \
+                CWARN("%s: slow %s %lus\n", obd->obd_name, msg,           \
+                      (jiffies - start) / CFS_HZ);                        \
+        else                                                              \
+                CERROR("%s: slow %s %lus\n", obd->obd_name, msg,          \
+                       (jiffies - start) / CFS_HZ);                       \
+} while (0)
+
+#define fsfilt_check_slow(obd, start, msg)              \
+do {                                                    \
+        __fsfilt_check_slow(obd, start, msg);           \
+        start = jiffies;                                \
+} while (0)
+
+static inline void *fsfilt_start_log(struct obd_device *obd,
+                                     struct inode *inode, int op,
+                                     struct obd_trans_info *oti, int logs)
 {
         unsigned long now = jiffies;
         void *parent_handle = oti ? oti->oti_handle : NULL;
         void *handle;
 
-        handle = obd->obd_fsops->fs_brw_start(objcount, fso, niocount,
-                                              parent_handle);
-        CDEBUG(D_HA, "started handle %p (%p)\n", handle, parent_handle);
+        handle = obd->obd_fsops->fs_start(inode, op, parent_handle, logs);
+        CDEBUG(D_INFO, "started handle %p (%p)\n", handle, parent_handle);
 
         if (oti != NULL) {
                 if (parent_handle == NULL) {
                         oti->oti_handle = handle;
                 } else if (handle != parent_handle) {
                         CERROR("mismatch: parent %p, handle %p, oti %p\n",
-                               parent_handle, handle, oti->oti_handle);
+                               parent_handle, handle, oti);
                         LBUG();
                 }
         }
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
+        fsfilt_check_slow(obd, now, "journal start");
         return handle;
 }
 
@@ -135,87 +148,44 @@ static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode,
 {
         unsigned long now = jiffies;
         int rc = obd->obd_fsops->fs_commit(inode, handle, force_sync);
-        CDEBUG(D_HA, "committing handle %p\n", handle);
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
-        return rc;
-}
-
-static inline int fsfilt_setattr(struct obd_device *obd, struct dentry *dentry,
-                                 void *handle, struct iattr *iattr,int do_trunc)
-{
-        unsigned long now = jiffies;
-        int rc;
-        rc = obd->obd_fsops->fs_setattr(dentry, handle, iattr, do_trunc);
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long setattr time %lus\n", (jiffies - now) / HZ);
-        return rc;
-}
-
-static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode,
-                                void *handle, void *md, int size)
-{
-        return obd->obd_fsops->fs_set_md(inode, handle, md, size);
-}
-
-static inline int fsfilt_get_md(struct obd_device *obd, struct inode *inode,
-                                void *md, int size)
-{
-        return obd->obd_fsops->fs_get_md(inode, md, size);
-}
+        CDEBUG(D_INFO, "committing handle %p\n", handle);
 
-static inline ssize_t fsfilt_readpage(struct obd_device *obd,
-                                      struct file *file, char *buf,
-                                      size_t count, loff_t *offset)
-{
-        return obd->obd_fsops->fs_readpage(file, buf, count, offset);
-}
+        fsfilt_check_slow(obd, now, "journal start");
 
-static inline int fsfilt_journal_data(struct obd_device *obd, struct file *file)
-{
-        return obd->obd_fsops->fs_journal_data(file);
+        return rc;
 }
 
-static inline int fsfilt_set_last_rcvd(struct obd_device *obd, __u64 last_rcvd,
-                                       void *handle, fsfilt_cb_t cb_func,
-                                       void *cb_data)
+static inline int fsfilt_map_inode_pages(struct obd_device *obd,
+                                         struct inode *inode,
+                                         struct page **page, int pages,
+                                         unsigned long *blocks, int *created,
+                                        int create, struct mutex *mutex)
 {
-        return obd->obd_fsops->fs_set_last_rcvd(obd, last_rcvd, handle,
-                                                cb_func, cb_data);
+        return obd->obd_fsops->fs_map_inode_pages(inode, page, pages, blocks,
+                                                  created, create, mutex);
 }
 
-static inline int fsfilt_statfs(struct obd_device *obd, struct super_block *fs,
-                                struct obd_statfs *osfs)
+static inline int fsfilt_read_record(struct obd_device *obd, struct file *file,
+                                     void *buf, loff_t size, loff_t *offs)
 {
-        return obd->obd_fsops->fs_statfs(fs, osfs);
+        return obd->obd_fsops->fs_read_record(file, buf, size, offs);
 }
 
-static inline int fsfilt_sync(struct obd_device *obd, struct super_block *fs)
+static inline int fsfilt_write_record(struct obd_device *obd, struct file *file,
+                                      void *buf, loff_t size, loff_t *offs,
+                                      int force_sync)
 {
-        return obd->obd_fsops->fs_sync(fs);
+        return obd->obd_fsops->fs_write_record(file, buf, size,offs,force_sync);
 }
 
-static inline int fs_prep_san_write(struct obd_device *obd,
-                                    struct inode *inode,
-                                    long *blocks,
-                                    int nblocks,
-                                    loff_t newsize)
+static inline int fsfilt_setup(struct obd_device *obd, struct super_block *fs)
 {
-        return obd->obd_fsops->fs_prep_san_write(inode, blocks,
-                                                 nblocks, newsize);
+        if (obd->obd_fsops->fs_setup)
+                return obd->obd_fsops->fs_setup(fs);
+        return 0;
 }
 
-static inline int fsfilt_read_record(struct obd_device *obd, struct file *file,
-                                     char *buf, loff_t size, loff_t *offs)
-{
-        return obd->obd_fsops->fs_read_record(file, buf, size, offs);
-}
 
-static inline int fsfilt_write_record(struct obd_device *obd, struct file *file,
-                                      char *buf, loff_t size, loff_t *offs)
-{
-        return obd->obd_fsops->fs_write_record(file, buf, size, offs);
-}
 
 #endif /* __KERNEL__ */