Whamcloud - gitweb
LU-2158 lvfs: move ldiskfs only functions to osd-ldiskfs
authorJames Simmons <uja.ornl@gmail.com>
Tue, 5 Feb 2013 15:24:09 +0000 (10:24 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 20 Feb 2013 03:40:56 +0000 (22:40 -0500)
Currently a lot of functions exist in the lvfs layer
that really belongs to different parts of the stack.
This patch moves osd-ldiskfs specific code that
is located in the lvfs layer into the proper
location.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: Ia197391599cc7fffad396d487873edd9d6c0b1c4
Reviewed-on: http://review.whamcloud.com/5246
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/include/linux/lvfs.h
lustre/include/linux/lvfs_linux.h
lustre/lvfs/lvfs_linux.c
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_handler.c

index 260cb9f..652d8d2 100644 (file)
@@ -96,8 +96,6 @@ struct lvfs_run_ctxt {
 
 #ifdef __KERNEL__
 
 
 #ifdef __KERNEL__
 
-struct dentry *simple_mkdir(struct dentry *dir, struct vfsmount *mnt, 
-                            const char *name, int mode, int fix);
 int lustre_rename(struct dentry *dir, struct vfsmount *mnt, char *oldname,
                   char *newname);
 
 int lustre_rename(struct dentry *dir, struct vfsmount *mnt, char *oldname,
                   char *newname);
 
index 9345dac..cb0523e 100644 (file)
@@ -63,12 +63,4 @@ struct l_readdir_callback {
         cfs_list_t            *lrc_list;
 };
 
         cfs_list_t            *lrc_list;
 };
 
-#define BDEVNAME_DECLARE_STORAGE(foo) char foo[BDEVNAME_SIZE]
-#define lvfs_sbdev(SB)       ((SB)->s_bdev)
-#define lvfs_sbdev_type      struct block_device *
-
-int __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev);
-
-int lvfs_check_rdonly(lvfs_sbdev_type dev);
-
 #endif /*  __LVFS_LINUX_H__ */
 #endif /*  __LVFS_LINUX_H__ */
index eb73a06..525e660 100644 (file)
@@ -204,55 +204,6 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
 }
 EXPORT_SYMBOL(pop_ctxt);
 
 }
 EXPORT_SYMBOL(pop_ctxt);
 
-/* utility to make a directory */
-struct dentry *simple_mkdir(struct dentry *dir, struct vfsmount *mnt, 
-                            const char *name, int mode, int fix)
-{
-        struct dentry *dchild;
-        int err = 0;
-        ENTRY;
-
-        // ASSERT_KERNEL_CTXT("kernel doing mkdir outside kernel context\n");
-        CDEBUG(D_INODE, "creating directory %.*s\n", (int)strlen(name), name);
-        dchild = ll_lookup_one_len(name, dir, strlen(name));
-        if (IS_ERR(dchild))
-                GOTO(out_up, dchild);
-
-        if (dchild->d_inode) {
-                int old_mode = dchild->d_inode->i_mode;
-                if (!S_ISDIR(old_mode)) {
-                        CERROR("found %s (%lu/%u) is mode %o\n", name,
-                               dchild->d_inode->i_ino,
-                               dchild->d_inode->i_generation, old_mode);
-                        GOTO(out_err, err = -ENOTDIR);
-                }
-
-                /* Fixup directory permissions if necessary */
-                if (fix && (old_mode & S_IALLUGO) != (mode & S_IALLUGO)) {
-                        CDEBUG(D_CONFIG,
-                               "fixing permissions on %s from %o to %o\n",
-                               name, old_mode, mode);
-                        dchild->d_inode->i_mode = (mode & S_IALLUGO) |
-                                                  (old_mode & ~S_IALLUGO);
-                        mark_inode_dirty(dchild->d_inode);
-                }
-                GOTO(out_up, dchild);
-        }
-
-        err = ll_vfs_mkdir(dir->d_inode, dchild, mnt, mode);
-        if (err)
-                GOTO(out_err, err);
-
-        RETURN(dchild);
-
-out_err:
-        dput(dchild);
-        dchild = ERR_PTR(err);
-out_up:
-        return dchild;
-}
-EXPORT_SYMBOL(simple_mkdir);
-
 /* utility to rename a file */
 int lustre_rename(struct dentry *dir, struct vfsmount *mnt,
                   char *oldname, char *newname)
 /* utility to rename a file */
 int lustre_rename(struct dentry *dir, struct vfsmount *mnt,
                   char *oldname, char *newname)
@@ -295,36 +246,6 @@ struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de,
 }
 EXPORT_SYMBOL(l_dentry_open);
 
 }
 EXPORT_SYMBOL(l_dentry_open);
 
-int __lvfs_set_rdonly(lvfs_sbdev_type dev, lvfs_sbdev_type jdev)
-{
-#ifdef HAVE_DEV_SET_RDONLY
-        if (jdev && (jdev != dev)) {
-                CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n",
-                       (long)jdev);
-                dev_set_rdonly(jdev);
-        }
-        CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev);
-        dev_set_rdonly(dev);
-
-        return 0;
-#else
-        CERROR("DEV %lx CANNOT BE SET READONLY\n", (long)dev);
-
-        return -EOPNOTSUPP;
-#endif
-}
-EXPORT_SYMBOL(__lvfs_set_rdonly);
-
-int lvfs_check_rdonly(lvfs_sbdev_type dev)
-{
-#ifdef HAVE_DEV_SET_RDONLY
-        return dev_check_rdonly(dev);
-#else
-        return 0;
-#endif
-}
-EXPORT_SYMBOL(lvfs_check_rdonly);
-
 void obd_update_maxusage()
 {
        __u64 max1, max2;
 void obd_update_maxusage()
 {
        __u64 max1, max2;
index e2d6025..03f7757 100644 (file)
@@ -52,7 +52,6 @@
  * OBD_FAIL_CHECK
  */
 #include <obd_support.h>
  * OBD_FAIL_CHECK
  */
 #include <obd_support.h>
-#include <lvfs.h>
 
 #include "osd_internal.h"
 #include "osd_oi.h"
 
 #include "osd_internal.h"
 #include "osd_oi.h"
@@ -76,6 +75,54 @@ static void osd_pop_ctxt(const struct osd_device *dev,
        pop_ctxt(save, new, NULL);
 }
 
        pop_ctxt(save, new, NULL);
 }
 
+/* utility to make a directory */
+static struct dentry *simple_mkdir(struct dentry *dir, struct vfsmount *mnt,
+                                  const char *name, int mode, int fix)
+{
+       struct dentry *dchild;
+       int err = 0;
+       ENTRY;
+
+       // ASSERT_KERNEL_CTXT("kernel doing mkdir outside kernel context\n");
+       CDEBUG(D_INODE, "creating directory %.*s\n", (int)strlen(name), name);
+       dchild = ll_lookup_one_len(name, dir, strlen(name));
+       if (IS_ERR(dchild))
+               GOTO(out_up, dchild);
+
+       if (dchild->d_inode) {
+               int old_mode = dchild->d_inode->i_mode;
+               if (!S_ISDIR(old_mode)) {
+                       CERROR("found %s (%lu/%u) is mode %o\n", name,
+                              dchild->d_inode->i_ino,
+                              dchild->d_inode->i_generation, old_mode);
+                       GOTO(out_err, err = -ENOTDIR);
+               }
+
+               /* Fixup directory permissions if necessary */
+               if (fix && (old_mode & S_IALLUGO) != (mode & S_IALLUGO)) {
+                       CDEBUG(D_CONFIG,
+                              "fixing permissions on %s from %o to %o\n",
+                              name, old_mode, mode);
+                       dchild->d_inode->i_mode = (mode & S_IALLUGO) |
+                                                 (old_mode & ~S_IALLUGO);
+                       mark_inode_dirty(dchild->d_inode);
+               }
+               GOTO(out_up, dchild);
+       }
+
+       err = ll_vfs_mkdir(dir->d_inode, dchild, mnt, mode);
+       if (err)
+               GOTO(out_err, err);
+
+       RETURN(dchild);
+
+out_err:
+       dput(dchild);
+       dchild = ERR_PTR(err);
+out_up:
+       return dchild;
+}
+
 int osd_last_rcvd_subdir_count(struct osd_device *osd)
 {
         struct lr_server_data lsd;
 int osd_last_rcvd_subdir_count(struct osd_device *osd)
 {
         struct lr_server_data lsd;
index d6c82a4..f6dad39 100644 (file)
@@ -53,8 +53,6 @@
 #include <linux/fs.h>
 /* XATTR_{REPLACE,CREATE} */
 #include <linux/xattr.h>
 #include <linux/fs.h>
 /* XATTR_{REPLACE,CREATE} */
 #include <linux/xattr.h>
-/* simple_mkdir() */
-#include <lvfs.h>
 
 /*
  * struct OBD_{ALLOC,FREE}*()
 
 /*
  * struct OBD_{ALLOC,FREE}*()
@@ -1075,14 +1073,31 @@ static int osd_commit_async(const struct lu_env *env,
 
 static int osd_ro(const struct lu_env *env, struct dt_device *d)
 {
 
 static int osd_ro(const struct lu_env *env, struct dt_device *d)
 {
-        struct super_block *sb = osd_sb(osd_dt_dev(d));
-        int rc;
-        ENTRY;
+       struct super_block *sb = osd_sb(osd_dt_dev(d));
+       struct block_device *dev = sb->s_bdev;
+#ifdef HAVE_DEV_SET_RDONLY
+       struct block_device *jdev = LDISKFS_SB(sb)->journal_bdev;
+       int rc = 0;
+#else
+       int rc = -EOPNOTSUPP;
+#endif
+       ENTRY;
 
 
+#ifdef HAVE_DEV_SET_RDONLY
        CERROR("*** setting %s read-only ***\n", osd_dt_dev(d)->od_svname);
 
        CERROR("*** setting %s read-only ***\n", osd_dt_dev(d)->od_svname);
 
-        rc = __lvfs_set_rdonly(sb->s_bdev, LDISKFS_SB(sb)->journal_bdev);
-        RETURN(rc);
+       if (jdev && (jdev != dev)) {
+               CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n",
+                      (long)jdev);
+               dev_set_rdonly(jdev);
+       }
+       CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev);
+       dev_set_rdonly(dev);
+#else
+       CERROR("%s: %lx CANNOT BE SET READONLY: rc = %d\n",
+              osd_dt_dev(d)->od_svname, (long)dev, rc);
+#endif
+       RETURN(rc);
 }
 
 /*
 }
 
 /*
@@ -5136,13 +5151,15 @@ static int osd_mount(const struct lu_env *env,
                GOTO(out, rc);
        }
 
                GOTO(out, rc);
        }
 
-       if (lvfs_check_rdonly(o->od_mnt->mnt_sb->s_bdev)) {
+#ifdef HAVE_DEV_SET_RDONLY
+       if (dev_check_rdonly(o->od_mnt->mnt_sb->s_bdev)) {
                CERROR("%s: underlying device %s is marked as read-only. "
                       "Setup failed\n", name, dev);
                mntput(o->od_mnt);
                o->od_mnt = NULL;
                GOTO(out, rc = -EROFS);
        }
                CERROR("%s: underlying device %s is marked as read-only. "
                       "Setup failed\n", name, dev);
                mntput(o->od_mnt);
                o->od_mnt = NULL;
                GOTO(out, rc = -EROFS);
        }
+#endif
 
        if (!LDISKFS_HAS_COMPAT_FEATURE(o->od_mnt->mnt_sb,
            LDISKFS_FEATURE_COMPAT_HAS_JOURNAL)) {
 
        if (!LDISKFS_HAS_COMPAT_FEATURE(o->od_mnt->mnt_sb,
            LDISKFS_FEATURE_COMPAT_HAS_JOURNAL)) {