Whamcloud - gitweb
capa_renew should increase the refc.
[fs/lustre-release.git] / lustre / include / linux / lustre_fsfilt.h
index 978fbe4..2461eaf 100644 (file)
@@ -39,10 +39,26 @@ struct fsfilt_objinfo {
         int fso_bufcnt;
 };
 
+/* lustre EA type (MEA, LOV, etc.) */
+enum ea_type {
+        EA_LOV   = (1 << 0),
+        EA_MEA   = (1 << 1),
+        EA_SID   = (1 << 2),
+        EA_KEY   = (1 << 3),
+        EA_PID   = (1 << 4),
+};
+
+#define XATTR_LUSTRE_MDS_LOV_EA "lov"
+#define XATTR_LUSTRE_MDS_MEA_EA "mea"
+#define XATTR_LUSTRE_MDS_SID_EA "sid"
+#define XATTR_LUSTRE_MDS_KEY_EA "key"
+#define XATTR_LUSTRE_MDS_PID_EA "pid"
+
 struct fsfilt_operations {
         struct list_head fs_list;
         struct module *fs_owner;
         char   *fs_type;
+        
         void   *(* fs_start)(struct inode *inode, int op, void *desc_private,
                              int logs);
         void   *(* fs_brw_start)(int objcount, struct fsfilt_objinfo *fso,
@@ -57,16 +73,14 @@ struct fsfilt_operations {
                                struct iattr *iattr, int do_trunc);
         int     (* fs_iocontrol)(struct inode *inode, struct file *file,
                                  unsigned int cmd, unsigned long arg);
+
+        /* two methods for setting getting diff. kind of EAs from inode. */
         int     (* fs_set_md)(struct inode *inode, void *handle, void *md,
-                              int size);
-        int     (* fs_get_md)(struct inode *inode, void *md, int size);
-
-        /* this method is needed to make IO operation fsfilt nature depend. */
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-        int     (* fs_send_bio)(struct inode *inode, struct bio *bio);
-#else
-        int     (* fs_send_bio)(struct inode *inode, struct kiobuf *bio);
-#endif
+                              int size, enum ea_type type);
+        int     (* fs_get_md)(struct inode *inode, void *md, int size,
+                              enum ea_type type);
+
+        int     (* fs_send_bio)(int rw, struct inode *inode, void *bio);
 
         /* methods for getting page from backing fs and putting page there
          * during IO. Used on OST. */
@@ -75,9 +89,10 @@ struct fsfilt_operations {
 
         ssize_t (* fs_readpage)(struct file *file, char *buf, size_t count,
                                 loff_t *offset);
-        int     (* fs_add_journal_cb)(struct obd_device *obd, struct super_block *sb,
-                                      __u64 last_rcvd, void *handle, fsfilt_cb_t cb_func,
-                                      void *cb_data);
+        int     (* fs_add_journal_cb)(struct obd_device *obd,
+                                      struct super_block *sb,
+                                      __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_map_inode_pages)(struct inode *inode, struct page **page,
@@ -91,15 +106,18 @@ struct fsfilt_operations {
         int     (* fs_read_record)(struct file *, void *, int size, loff_t *);
         int     (* fs_setup)(struct obd_device *, struct super_block *);
         
-        int     (* fs_post_setup)(struct obd_device *obd, struct vfsmount *mnt);
+        int     (* fs_post_setup)(struct obd_device *obd, struct vfsmount *mnt,
+                                  struct dentry *dentry);
         int     (* fs_post_cleanup)(struct obd_device *obd, struct vfsmount *mnt);
-        int     (* fs_get_reint_log_ctxt)(struct super_block *sb, 
-                                          struct llog_ctxt **ctxt);
+        int     (* fs_set_info)(struct super_block *, struct inode *,
+                                __u32, void *, __u32, void *);
+        int     (* fs_get_info)(struct super_block *, struct inode *,
+                                __u32, void *, __u32 *, void *);
         int     (* fs_set_fs_flags)(struct inode *inode, int flags);
         int     (* fs_clear_fs_flags)(struct inode *inode, int flags);
         int     (* fs_set_ost_flags)(struct super_block *sb);
         int     (* fs_set_mds_flags)(struct super_block *sb);
-        int     (* fs_precreate_rec)(struct dentry *dentry, int *num, 
+        int     (* fs_precreate_rec)(struct dentry *dentry, int *num,
                                      struct obdo *oa);
         int     (* fs_set_xattr)(struct inode *inode, void *handle, char *name,
                                  void *buffer, int buffer_size);
@@ -126,35 +144,43 @@ struct fsfilt_operations {
         int     (* fs_get_op_len)(int, struct fsfilt_objinfo *, int);
         int     (* fs_add_dir_entry)(struct obd_device *, struct dentry *,
                                      char *, int, unsigned long, unsigned long,
-                                     unsigned);
+                                     unsigned long, unsigned long);
         int     (* fs_del_dir_entry)(struct obd_device *, struct dentry *);
         /*snap operations*/
         int     (* fs_is_redirector)(struct inode *inode);
         int     (* fs_is_indirect)(struct inode *inode);
         
         struct inode * (* fs_create_indirect)(struct inode *pri, int index,
-                                              unsigned int gen, struct inode *parent,
+                                              unsigned int gen, 
+                                              struct inode *parent,
                                               int del);
         struct inode * (* fs_get_indirect)(struct inode *pri, int *table,
                                           int slot);
-        ino_t   (* fs_get_indirect_ino)(struct inode *pri, int index);
+        ino_t   (* fs_get_indirect_ino)(struct super_block *sb, ino_t pri, 
+                                        int index);
         int     (* fs_destroy_indirect)(struct inode *pri, int index,
                                         struct inode *next_ind);
         int     (* fs_restore_indirect)(struct inode *pri, int index);
         int     (* fs_iterate)(struct super_block *sb,
                               int (*repeat)(struct inode *inode, void *priv),
                               struct inode **start, void *priv, int flag);
-        int     (* fs_copy_block)(struct inode *dst, struct inode *src, int blk);
+        int     (* fs_copy_block)(struct inode *dst, struct inode *src, 
+                                  int blk);
         int     (* fs_set_indirect)(struct inode *pri, int index,
                                     ino_t ind_ino, ino_t parent_ino);
-        int     (* fs_snap_feature)(struct super_block *sb, int feature, int op);
-        int     (* fs_set_snap_info)(struct super_block *sb, struct inode *inode, 
-                                     void* key, __u32 keylen, void *val, 
-                                     __u32 *vallen); 
-        int     (* fs_get_snap_info)(struct super_block *sb, struct inode *inode,
-                                     void* key, __u32 keylen, void *val, 
-                                     __u32 *vallen); 
+        int     (* fs_snap_feature)(struct super_block *sb, int feature, 
+                                    int op);
+        int     (* fs_set_snap_info)(struct inode *inode, void* key, 
+                                     __u32 keylen, void *val, __u32 *vallen); 
+        int     (* fs_get_snap_info)(struct inode *inode, void* key, 
+                                     __u32 keylen, void *val, __u32 *vallen); 
         int     (* fs_set_snap_item)(struct super_block *sb, char *name);
+        int     (* fs_read_dotsnap_dir_page)(struct file *file, char *buf, 
+                                             size_t count, loff_t *ppos);
+        int     (* fs_dir_ent_size)(char *name);
+        int     (* fs_set_dir_ent)(struct super_block *sb, char *name, 
+                                   char *buf, int buf_off, int nlen, 
+                                   size_t count);
 };
 
 extern int fsfilt_register_ops(struct fsfilt_operations *fs_ops);
@@ -208,6 +234,16 @@ extern void fsfilt_put_ops(struct fsfilt_operations *fs_ops);
 #define LMV_EA  1
 #define LOV_EA  0
 
+#define fsfilt_check_slow(start, timeout, msg)                          \
+do {                                                                    \
+        if (time_before(jiffies, start + 15 * HZ))                      \
+                break;                                                  \
+        else if (time_before(jiffies, start + timeout / 2 * HZ))        \
+                CWARN("slow %s %lus\n", msg, (jiffies - start) / HZ);   \
+        else                                                            \
+                CERROR("slow %s %lus\n", msg, (jiffies - start) / HZ);  \
+} while (0)
+
 static inline void *
 fsfilt_start_ops(struct fsfilt_operations *ops, struct inode *inode,
                  int op, struct obd_trans_info *oti, int logs)
@@ -215,7 +251,7 @@ fsfilt_start_ops(struct fsfilt_operations *ops, struct inode *inode,
         unsigned long now = jiffies;
         void *parent_handle = oti ? oti->oti_handle : NULL;
         void *handle = ops->fs_start(inode, op, parent_handle, logs);
-        CDEBUG(D_HA, "started handle %p (%p)\n", handle, parent_handle);
+        CDEBUG(D_INFO, "started handle %p (%p)\n", handle, parent_handle);
 
         if (oti != NULL) {
                 if (parent_handle == NULL) {
@@ -226,8 +262,7 @@ fsfilt_start_ops(struct fsfilt_operations *ops, struct inode *inode,
                         LBUG();
                 }
         }
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
+        fsfilt_check_slow(now, 60, "journal start");
         return handle;
 }
 
@@ -258,10 +293,9 @@ fsfilt_commit_ops(struct fsfilt_operations *ops, struct super_block *sb,
 {
         unsigned long now = jiffies;
         int rc = ops->fs_commit(sb, inode, handle, force_sync);
-        CDEBUG(D_HA, "committing handle %p\n", handle);
+        CDEBUG(D_INFO, "committing handle %p\n", handle);
 
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
+        fsfilt_check_slow(now, 60, "journal start");
 
         return rc;
 }
@@ -291,7 +325,7 @@ fsfilt_brw_start_log(struct obd_device *obd, int objcount,
         void *parent_handle = oti ? oti->oti_handle : NULL;
         void *handle = obd->obd_fsops->fs_brw_start(objcount, fso, niocount, nb,
                                                     parent_handle, logs);
-        CDEBUG(D_HA, "started handle %p (%p)\n", handle, parent_handle);
+        CDEBUG(D_INFO, "started handle %p (%p)\n", handle, parent_handle);
 
         if (oti != NULL) {
                 if (parent_handle == NULL) {
@@ -302,8 +336,7 @@ fsfilt_brw_start_log(struct obd_device *obd, int objcount,
                         LBUG();
                 }
         }
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
+        fsfilt_check_slow(now, obd_timeout, "journal start");
 
         return handle;
 }
@@ -323,9 +356,8 @@ fsfilt_commit_async(struct obd_device *obd, struct inode *inode,
         unsigned long now = jiffies;
         int rc = obd->obd_fsops->fs_commit_async(inode, handle, wait_handle);
 
-        CDEBUG(D_HA, "committing handle %p (async)\n", *wait_handle);
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
+        CDEBUG(D_INFO, "committing handle %p (async)\n", *wait_handle);
+        fsfilt_check_slow(now, obd_timeout, "journal start");
 
         return rc;
 }
@@ -335,9 +367,8 @@ fsfilt_commit_wait(struct obd_device *obd, struct inode *inode, void *handle)
 {
         unsigned long now = jiffies;
         int rc = obd->obd_fsops->fs_commit_wait(inode, handle);
-        CDEBUG(D_HA, "waiting for completion %p\n", handle);
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
+        CDEBUG(D_INFO, "waiting for completion %p\n", handle);
+        fsfilt_check_slow(now, obd_timeout, "journal start");
         return rc;
 }
 
@@ -348,8 +379,7 @@ fsfilt_setattr(struct obd_device *obd, struct dentry *dentry,
         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);
+        fsfilt_check_slow(now, obd_timeout, "setattr");
         return rc;
 }
 
@@ -368,31 +398,38 @@ static inline int fsfilt_setup(struct obd_device *obd,
                 return obd->obd_fsops->fs_setup(obd, fs);
         return 0;
 }
+
 static inline int
 fsfilt_set_md(struct obd_device *obd, struct inode *inode,
-              void *handle, void *md, int size)
+              void *handle, void *md, int size, enum ea_type type)
 {
-        return obd->obd_fsops->fs_set_md(inode, handle, md, size);
+        if (!obd->obd_fsops->fs_set_md)
+                return -ENOSYS;
+        
+        return obd->obd_fsops->fs_set_md(inode, handle, md,
+                                         size, type);
 }
 
 static inline int
 fsfilt_get_md(struct obd_device *obd, struct inode *inode,
-              void *md, int size)
+              void *md, int size, enum ea_type type)
 {
-        return obd->obd_fsops->fs_get_md(inode, md, size);
+        if (!obd->obd_fsops->fs_get_md)
+                return -ENOSYS;
+        
+        return obd->obd_fsops->fs_get_md(inode, md, size,
+                                         type);
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-static inline int
-fsfilt_send_bio(struct obd_device *obd, struct inode *inode,
-                struct bio *bio)
-#else
-static inline int
-fsfilt_send_bio(struct obd_device *obd, struct inode *inode,
-                struct kiobuf *bio)
-#endif
+static inline int fsfilt_send_bio(int rw, struct obd_device *obd,
+                                  struct inode *inode, void *bio)
 {
-        return obd->obd_fsops->fs_send_bio(inode, bio);
+        LASSERTF(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ, "%x\n", rw);
+
+        if (rw == OBD_BRW_READ)
+                return obd->obd_fsops->fs_send_bio(READ, inode, bio);
+        else
+                return obd->obd_fsops->fs_send_bio(WRITE, inode, bio);
 }
 
 static inline int
@@ -416,8 +453,7 @@ fsfilt_putpage(struct obd_device *obd, struct inode *inode,
 
         rc = obd->obd_fsops->fs_putpage(inode, page);
 
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long putpage time %lus\n", (jiffies - now) / HZ);
+        fsfilt_check_slow(now, obd_timeout, "putpage");
 
         return rc;
 }
@@ -439,8 +475,7 @@ fsfilt_getpage(struct obd_device *obd, struct inode *inode,
 
         page = obd->obd_fsops->fs_getpage(inode, index);
 
-        if (time_after(jiffies, now + 15 * HZ))
-                CERROR("long getpage time %lus\n", (jiffies - now) / HZ);
+        fsfilt_check_slow(now, obd_timeout, "getpage");
 
         return page;
 }
@@ -454,10 +489,10 @@ fsfilt_readpage(struct obd_device *obd, struct file *file, char *buf,
 
 static inline int
 fsfilt_add_journal_cb(struct obd_device *obd, struct super_block *sb,
-                      __u64 last_rcvd, void *handle, fsfilt_cb_t cb_func,
+                      __u64 last_num, void *handle, fsfilt_cb_t cb_func,
                       void *cb_data)
 {
-        return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_rcvd, handle,
+        return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_num, handle,
                                                  cb_func, cb_data);
 }
 
@@ -575,6 +610,7 @@ fsfilt_clear_fs_flags(struct obd_device *obd, struct inode *inode, int flags)
                 return obd->obd_fsops->fs_clear_fs_flags(inode, flags);
         return 0;
 }
+
 static inline int 
 fsfilt_precreate_rec(struct obd_device *obd, struct dentry *dentry,
                      int *num, struct obdo *oa)
@@ -585,11 +621,11 @@ fsfilt_precreate_rec(struct obd_device *obd, struct dentry *dentry,
 }
 
 static inline int 
-fsfilt_post_setup(struct obd_device *obd)
+fsfilt_post_setup(struct obd_device *obd, struct dentry *de)
 {
         if (obd->obd_fsops->fs_post_setup)
                 return obd->obd_fsops->fs_post_setup(obd, 
-                                obd->obd_lvfs_ctxt.pwdmnt);
+                                obd->obd_lvfs_ctxt.pwdmnt, de);
         return 0;
 }
 
@@ -625,12 +661,25 @@ fsfilt_free_write_extents(struct obd_device *obd,
 }
 
 static inline int 
-fsfilt_get_reint_log_ctxt(struct obd_device *obd,
-                          struct super_block *sb, 
-                          struct llog_ctxt **ctxt)
+fsfilt_set_info(struct obd_device *obd, struct super_block *sb, 
+                struct inode * inode, __u32 keylen, void * key,
+                __u32 valsize, void * val)
+{
+        if (obd->obd_fsops->fs_set_info)
+                return obd->obd_fsops->fs_set_info(sb, inode, 
+                                                   keylen, key,
+                                                   valsize, val);
+        return 0;
+}
+
+static inline int 
+fsfilt_get_info(struct obd_device *obd, struct super_block *sb, 
+                struct inode * inode, __u32 keylen, void * key,
+                __u32 * valsize, void * val)
 {
-        if (obd->obd_fsops->fs_get_reint_log_ctxt)
-                return obd->obd_fsops->fs_get_reint_log_ctxt(sb, ctxt);
+        if (obd->obd_fsops->fs_get_info)
+                return obd->obd_fsops->fs_get_info(sb, inode, keylen, key,
+                                                   valsize, val);
         return 0;
 }
 
@@ -653,11 +702,15 @@ fsfilt_set_mds_flags(struct obd_device *obd, struct super_block *sb)
 static inline int 
 fsfilt_add_dir_entry(struct obd_device *obd, struct dentry *dir,
                      char *name, int namelen, unsigned long ino,
-                     unsigned long generation, unsigned mds)
+                     unsigned long generation, unsigned long mds,
+                     unsigned long fid)
 {
         LASSERT(obd->obd_fsops->fs_add_dir_entry);
+        
         return obd->obd_fsops->fs_add_dir_entry(obd, dir, name,
-                                                namelen, ino, generation, mds);
+                                                namelen, ino,
+                                                generation, mds,
+                                                fid);
 }
 
 static inline int