Skip to content

Commit

Permalink
LU-2158 lvfs: move ldiskfs only functions to osd-ldiskfs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Change-Id: Ia197391599cc7fffad396d487873edd9d6c0b1c4
Reviewed-on: http://review.whamcloud.com/5246
Tested-by: Hudson
Tested-by: Maloo <[email protected]>
Reviewed-by: Mike Pershin <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
  • Loading branch information
jasimmons1973 authored and Oleg Drokin committed Feb 20, 2013
1 parent 42472bb commit 47811ca
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 98 deletions.
2 changes: 0 additions & 2 deletions lustre/include/linux/lvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ struct lvfs_run_ctxt {

#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);

Expand Down
8 changes: 0 additions & 8 deletions lustre/include/linux/lvfs_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,4 @@ struct l_readdir_callback {
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__ */
79 changes: 0 additions & 79 deletions lustre/lvfs/lvfs_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,55 +204,6 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
}
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)
Expand Down Expand Up @@ -295,36 +246,6 @@ struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de,
}
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;
Expand Down
49 changes: 48 additions & 1 deletion lustre/osd-ldiskfs/osd_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
* OBD_FAIL_CHECK
*/
#include <obd_support.h>
#include <lvfs.h>

#include "osd_internal.h"
#include "osd_oi.h"
Expand All @@ -76,6 +75,54 @@ static void osd_pop_ctxt(const struct osd_device *dev,
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;
Expand Down
33 changes: 25 additions & 8 deletions lustre/osd-ldiskfs/osd_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
#include <linux/fs.h>
/* XATTR_{REPLACE,CREATE} */
#include <linux/xattr.h>
/* simple_mkdir() */
#include <lvfs.h>

/*
* struct OBD_{ALLOC,FREE}*()
Expand Down Expand Up @@ -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)
{
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);

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);
}

/*
Expand Down Expand Up @@ -5136,13 +5151,15 @@ static int osd_mount(const struct lu_env *env,
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);
}
#endif

if (!LDISKFS_HAS_COMPAT_FEATURE(o->od_mnt->mnt_sb,
LDISKFS_FEATURE_COMPAT_HAS_JOURNAL)) {
Expand Down

0 comments on commit 47811ca

Please sign in to comment.