Whamcloud - gitweb
b=19681
authorgirish <girish>
Thu, 4 Jun 2009 11:52:08 +0000 (11:52 +0000)
committergirish <girish>
Thu, 4 Jun 2009 11:52:08 +0000 (11:52 +0000)
i=adilger
i=johann

pass dentry and vfsmnt to fsfilt_iocontrol

lustre/include/linux/lustre_fsfilt.h
lustre/include/obd.h
lustre/lvfs/fsfilt_ext3.c
lustre/mds/handler.c
lustre/mds/mds_fs.c
lustre/mds/mds_reint.c
lustre/obdfilter/filter.c

index 0e9f801..65a9e67 100644 (file)
@@ -331,11 +331,24 @@ static inline int fsfilt_setattr(struct obd_device *obd, struct dentry *dentry,
         return rc;
 }
 
-static inline int fsfilt_iocontrol(struct obd_device *obd, struct inode *inode,
-                                   struct file *file, unsigned int cmd,
-                                   unsigned long arg)
+static inline int fsfilt_iocontrol(struct obd_device *obd, struct dentry *dentry,
+                                   unsigned int cmd, unsigned long arg)
 {
-        return obd->obd_fsops->fs_iocontrol(inode, file, cmd, arg);
+        struct file *dummy_file = NULL;
+        int ret;
+
+        OBD_ALLOC_PTR(dummy_file);
+        if (!dummy_file)
+                return(-ENOMEM);
+
+        dummy_file->f_dentry = dentry;
+        dummy_file->f_vfsmnt = obd->u.obt.obt_vfsmnt;
+
+        ret = obd->obd_fsops->fs_iocontrol(dentry->d_inode, dummy_file, cmd,
+                                           arg);
+
+        OBD_FREE_PTR(dummy_file);
+        return ret;
 }
 
 static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode,
index a906c12..0762e06 100644 (file)
@@ -297,6 +297,8 @@ struct obd_device_target {
         lustre_quota_version_t    obt_qfmt;
         __u32                     obt_stale_export_age;
         spinlock_t                obt_trans_table_lock;
+        struct vfsmount          *obt_vfsmnt;
+        struct file              *obt_health_check_filp;
 };
 
 typedef void (*obd_pin_extent_cb)(void *data);
@@ -316,12 +318,10 @@ struct filter_obd {
         /* NB this field MUST be first */
         struct obd_device_target fo_obt;
         const char          *fo_fstype;
-        struct vfsmount     *fo_vfsmnt;
         cfs_dentry_t        *fo_dentry_O;
         cfs_dentry_t       **fo_dentry_O_groups;
         cfs_dentry_t       **fo_dentry_O_sub;
         spinlock_t           fo_objidlock;      /* protect fo_lastobjid */
-        struct file         *fo_health_check_filp;
 
         int                  fo_destroy_in_progress;
         struct semaphore     fo_create_lock;
@@ -381,6 +381,7 @@ struct filter_obd {
 #define fo_fsd                  fo_obt.obt_lsd
 #define fo_last_rcvd_slots      fo_obt.obt_client_bitmap
 #define fo_mount_count          fo_obt.obt_mount_count
+#define fo_vfsmnt               fo_obt.obt_vfsmnt
 
 #define OSC_MAX_RIF_DEFAULT       8
 #define OSC_MAX_RIF_MAX         256
@@ -525,7 +526,6 @@ struct mds_obd {
         struct ptlrpc_service           *mds_service;
         struct ptlrpc_service           *mds_setattr_service;
         struct ptlrpc_service           *mds_readpage_service;
-        struct vfsmount                 *mds_vfsmnt;
         cfs_dentry_t                    *mds_fid_de;
         int                              mds_max_mdsize;
         int                              mds_max_cookiesize;
@@ -555,7 +555,6 @@ struct mds_obd {
         __u32                            mds_lov_objid_lastpage;
         __u32                            mds_lov_objid_lastidx;
 
-        struct file                     *mds_health_check_filp;
         struct upcall_cache             *mds_group_hash;
 
         struct lustre_quota_info         mds_quota_info;
@@ -582,6 +581,7 @@ struct mds_obd {
 #define mds_client_bitmap        mds_obt.obt_client_bitmap
 #define mds_mount_count          mds_obt.obt_mount_count
 #define mds_last_transno         mds_obt.obt_last_transno
+#define mds_vfsmnt               mds_obt.obt_vfsmnt
 
 /* lov objid */
 #define mds_max_ost_index  (0xFFFF)
index 8cd4128..0268ce4 100644 (file)
@@ -597,13 +597,10 @@ static int fsfilt_ext3_setattr(struct dentry *dentry, void *handle,
         RETURN(rc);
 }
 
-static int fsfilt_ext3_iocontrol(struct inode * inode, struct file *file,
+static int fsfilt_ext3_iocontrol(struct inode *inode, struct file *file,
                                  unsigned int cmd, unsigned long arg)
 {
         int rc = 0;
-#ifdef HAVE_EXT4_LDISKFS
-        struct file dummy_file;
-#endif
         ENTRY;
 
         /* FIXME: Can't do this because of nested transaction deadlock */
@@ -613,18 +610,9 @@ static int fsfilt_ext3_iocontrol(struct inode * inode, struct file *file,
         }
 
 #ifdef HAVE_EXT4_LDISKFS
-        /* ext4_ioctl does not have a inode argument, so create a dummy file */
-        if (file == NULL) {
-                OBD_ALLOC_PTR(dummy_file.f_dentry);
-                if (dummy_file.f_dentry == NULL)
-                        RETURN(-ENOMEM);
-                dummy_file.f_dentry->d_inode = inode;
-        }
+        /* ext4_ioctl does not have a inode argument */
         if (inode->i_fop->unlocked_ioctl)
-                rc = inode->i_fop->unlocked_ioctl(file ?: &dummy_file, cmd,arg);
-
-        if (file == NULL)
-                OBD_FREE_PTR(dummy_file.f_dentry);
+                rc = inode->i_fop->unlocked_ioctl(file, cmd, arg);
 #else
         if (inode->i_fop->ioctl)
                 rc = inode->i_fop->ioctl(inode, file, cmd, arg);
index 8eb23c3..f750cec 100644 (file)
@@ -785,7 +785,7 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
 
                 /* We only return the full set of flags on ioctl, otherwise we
                  * get enough flags from the inode in mds_pack_inode2body(). */
-                rc = fsfilt_iocontrol(obd, inode, NULL, FSFILT_IOC_GETFLAGS,
+                rc = fsfilt_iocontrol(obd, dentry, FSFILT_IOC_GETFLAGS,
                                       (long)&flags);
                 if (rc == 0)
                         body->flags = flags | MDS_BFLAG_EXT_FLAGS;
@@ -2763,8 +2763,8 @@ static int mds_health_check(struct obd_device *obd)
                 rc = 1;
 
 #ifdef USE_HEALTH_CHECK_WRITE
-        LASSERT(mds->mds_health_check_filp != NULL);
-        rc |= !!lvfs_check_io_health(obd, mds->mds_health_check_filp);
+        LASSERT(mds->mds_obt.obt_health_check_filp != NULL);
+        rc |= !!lvfs_check_io_health(obd, mds->mds_obt.obt_health_check_filp);
 #endif
 
         return rc;
index b433a57..1e078dc 100644 (file)
@@ -831,7 +831,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
                 CERROR("cannot open/create %s file: rc = %d\n",HEALTH_CHECK,rc);
                 GOTO(err_lov_objid, rc = PTR_ERR(file));
         }
-        mds->mds_health_check_filp = file;
+        mds->mds_obt.obt_health_check_filp = file;
         if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
                 CERROR("%s is not a regular file!: mode = %o\n", HEALTH_CHECK,
                        file->f_dentry->d_inode->i_mode);
@@ -846,8 +846,8 @@ err_pop:
         return rc;
 
 err_health_check:
-        if (mds->mds_health_check_filp &&
-            filp_close(mds->mds_health_check_filp, 0))
+        if (mds->mds_obt.obt_health_check_filp &&
+            filp_close(mds->mds_obt.obt_health_check_filp, 0))
                 CERROR("can't close %s after error\n", HEALTH_CHECK);
 err_lov_objid:
          mds_lov_destroy_objids(obd);
@@ -896,9 +896,9 @@ int mds_fs_cleanup(struct obd_device *obd)
 
         mds_lov_destroy_objids(obd);
 
-        if (mds->mds_health_check_filp) {
-                rc = filp_close(mds->mds_health_check_filp, 0);
-                mds->mds_health_check_filp = NULL;
+        if (mds->mds_obt.obt_health_check_filp) {
+                rc = filp_close(mds->mds_obt.obt_health_check_filp, 0);
+                mds->mds_obt.obt_health_check_filp = NULL;
                 if (rc)
                         CERROR("%s file won't close, rc=%d\n", HEALTH_CHECK,rc);
         }
index 3809c8b..8fc9a40 100644 (file)
@@ -771,7 +771,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                 GOTO(cleanup, rc);
 
         if (rec->ur_iattr.ia_valid & ATTR_ATTR_FLAG) {  /* ioctl */
-                rc = fsfilt_iocontrol(obd, inode, NULL, FSFILT_IOC_SETFLAGS,
+                rc = fsfilt_iocontrol(obd, de, FSFILT_IOC_SETFLAGS,
                                       (long)&rec->ur_flags);
         } else if (rec->ur_iattr.ia_valid) {            /* setattr */
                 rc = fsfilt_setattr(obd, de, handle, &rec->ur_iattr, 0);
index 3d1b6c1..c534c21 100644 (file)
@@ -1232,7 +1232,7 @@ static int filter_prep(struct obd_device *obd)
                        HEALTH_CHECK, rc);
                 GOTO(err_filp, rc);
         }
-        filter->fo_health_check_filp = file;
+        filter->fo_obt.obt_health_check_filp = file;
         if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
                 CERROR("%s is not a regular file!: mode = %o\n", HEALTH_CHECK,
                        file->f_dentry->d_inode->i_mode);
@@ -1254,9 +1254,9 @@ static int filter_prep(struct obd_device *obd)
         //class_disconnect_exports(obd, 0);
         filter_free_server_data(filter);
  err_health_check:
-        if (filp_close(filter->fo_health_check_filp, 0))
+        if (filp_close(filter->fo_obt.obt_health_check_filp, 0))
                 CERROR("can't close %s after error\n", HEALTH_CHECK);
-        filter->fo_health_check_filp = NULL;
+        filter->fo_obt.obt_health_check_filp = NULL;
  err_filp:
         if (filp_close(filter->fo_rcvd_filp, 0))
                 CERROR("can't close %s after error\n", LAST_RCVD);
@@ -1293,8 +1293,8 @@ static void filter_post(struct obd_device *obd)
         if (rc)
                 CERROR("error closing %s: rc = %d\n", LAST_RCVD, rc);
 
-        rc = filp_close(filter->fo_health_check_filp, 0);
-        filter->fo_health_check_filp = NULL;
+        rc = filp_close(filter->fo_obt.obt_health_check_filp, 0);
+        filter->fo_obt.obt_health_check_filp = NULL;
         if (rc)
                 CERROR("error closing %s: rc = %d\n", HEALTH_CHECK, rc);
 
@@ -2821,7 +2821,7 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
         }
 
         if (oa->o_valid & OBD_MD_FLFLAGS) {
-                rc = fsfilt_iocontrol(exp->exp_obd, inode, NULL,
+                rc = fsfilt_iocontrol(exp->exp_obd, dentry,
                                       FSFILT_IOC_SETFLAGS, (long)&oa->o_flags);
         } else {
                 rc = fsfilt_setattr(exp->exp_obd, dentry, handle, &iattr, 1);
@@ -3810,8 +3810,8 @@ static int filter_get_info(struct obd_export *exp, __u32 keylen,
                 memcpy(fiemap, &fm_key->fiemap, sizeof(*fiemap));
                 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
-                rc = fsfilt_iocontrol(obd, dentry->d_inode, NULL,
-                                      FSFILT_IOC_FIEMAP, (long)fiemap);
+                rc = fsfilt_iocontrol(obd, dentry, FSFILT_IOC_FIEMAP,
+                                      (long)fiemap);
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
                 f_dput(dentry);
@@ -3947,8 +3947,8 @@ static int filter_health_check(struct obd_device *obd)
                 rc = 1;
 
 #ifdef USE_HEALTH_CHECK_WRITE
-        LASSERT(filter->fo_health_check_filp != NULL);
-        rc |= !!lvfs_check_io_health(obd, filter->fo_health_check_filp);
+        LASSERT(filter->fo_obt.obt_health_check_filp != NULL);
+        rc |= !!lvfs_check_io_health(obd, filter->fo_obt.obt_health_check_filp);
 #endif
 
         return rc;