Commit 1cdb0cb6 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Miklos Szeredi

ovl: propagate ovl_fs to ovl_decode_real_fh and ovl_encode_real_fh

This will be used in next patch to be able to change uuid checks and add
uuid nullification based on ofs->config.index for a new "uuid=off" mode.
Reviewed-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 3650b228
...@@ -275,7 +275,8 @@ int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat) ...@@ -275,7 +275,8 @@ int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat)
return err; return err;
} }
struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper) struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
bool is_upper)
{ {
struct ovl_fh *fh; struct ovl_fh *fh;
int fh_type, dwords; int fh_type, dwords;
...@@ -328,8 +329,8 @@ struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper) ...@@ -328,8 +329,8 @@ struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper)
return ERR_PTR(err); return ERR_PTR(err);
} }
int ovl_set_origin(struct dentry *dentry, struct dentry *lower, int ovl_set_origin(struct ovl_fs *ofs, struct dentry *dentry,
struct dentry *upper) struct dentry *lower, struct dentry *upper)
{ {
const struct ovl_fh *fh = NULL; const struct ovl_fh *fh = NULL;
int err; int err;
...@@ -340,7 +341,7 @@ int ovl_set_origin(struct dentry *dentry, struct dentry *lower, ...@@ -340,7 +341,7 @@ int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
* up and a pure upper inode. * up and a pure upper inode.
*/ */
if (ovl_can_decode_fh(lower->d_sb)) { if (ovl_can_decode_fh(lower->d_sb)) {
fh = ovl_encode_real_fh(lower, false); fh = ovl_encode_real_fh(ofs, lower, false);
if (IS_ERR(fh)) if (IS_ERR(fh))
return PTR_ERR(fh); return PTR_ERR(fh);
} }
...@@ -362,7 +363,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper, ...@@ -362,7 +363,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
const struct ovl_fh *fh; const struct ovl_fh *fh;
int err; int err;
fh = ovl_encode_real_fh(upper, true); fh = ovl_encode_real_fh(ofs, upper, true);
if (IS_ERR(fh)) if (IS_ERR(fh))
return PTR_ERR(fh); return PTR_ERR(fh);
...@@ -380,6 +381,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper, ...@@ -380,6 +381,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
static int ovl_create_index(struct dentry *dentry, struct dentry *origin, static int ovl_create_index(struct dentry *dentry, struct dentry *origin,
struct dentry *upper) struct dentry *upper)
{ {
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
struct dentry *indexdir = ovl_indexdir(dentry->d_sb); struct dentry *indexdir = ovl_indexdir(dentry->d_sb);
struct inode *dir = d_inode(indexdir); struct inode *dir = d_inode(indexdir);
struct dentry *index = NULL; struct dentry *index = NULL;
...@@ -402,7 +404,7 @@ static int ovl_create_index(struct dentry *dentry, struct dentry *origin, ...@@ -402,7 +404,7 @@ static int ovl_create_index(struct dentry *dentry, struct dentry *origin,
if (WARN_ON(ovl_test_flag(OVL_INDEX, d_inode(dentry)))) if (WARN_ON(ovl_test_flag(OVL_INDEX, d_inode(dentry))))
return -EIO; return -EIO;
err = ovl_get_index_name(origin, &name); err = ovl_get_index_name(ofs, origin, &name);
if (err) if (err)
return err; return err;
...@@ -411,7 +413,7 @@ static int ovl_create_index(struct dentry *dentry, struct dentry *origin, ...@@ -411,7 +413,7 @@ static int ovl_create_index(struct dentry *dentry, struct dentry *origin,
if (IS_ERR(temp)) if (IS_ERR(temp))
goto free_name; goto free_name;
err = ovl_set_upper_fh(OVL_FS(dentry->d_sb), upper, temp); err = ovl_set_upper_fh(ofs, upper, temp);
if (err) if (err)
goto out; goto out;
...@@ -521,7 +523,7 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) ...@@ -521,7 +523,7 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp)
* hard link. * hard link.
*/ */
if (c->origin) { if (c->origin) {
err = ovl_set_origin(c->dentry, c->lowerpath.dentry, temp); err = ovl_set_origin(ofs, c->dentry, c->lowerpath.dentry, temp);
if (err) if (err)
return err; return err;
} }
...@@ -700,7 +702,7 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c) ...@@ -700,7 +702,7 @@ static int ovl_copy_up_tmpfile(struct ovl_copy_up_ctx *c)
static int ovl_do_copy_up(struct ovl_copy_up_ctx *c) static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
{ {
int err; int err;
struct ovl_fs *ofs = c->dentry->d_sb->s_fs_info; struct ovl_fs *ofs = OVL_FS(c->dentry->d_sb);
bool to_index = false; bool to_index = false;
/* /*
...@@ -722,7 +724,7 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c) ...@@ -722,7 +724,7 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
if (to_index) { if (to_index) {
c->destdir = ovl_indexdir(c->dentry->d_sb); c->destdir = ovl_indexdir(c->dentry->d_sb);
err = ovl_get_index_name(c->lowerpath.dentry, &c->destname); err = ovl_get_index_name(ofs, c->lowerpath.dentry, &c->destname);
if (err) if (err)
return err; return err;
} else if (WARN_ON(!c->parent)) { } else if (WARN_ON(!c->parent)) {
......
...@@ -211,7 +211,8 @@ static int ovl_check_encode_origin(struct dentry *dentry) ...@@ -211,7 +211,8 @@ static int ovl_check_encode_origin(struct dentry *dentry)
return 1; return 1;
} }
static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen) static int ovl_dentry_to_fid(struct ovl_fs *ofs, struct dentry *dentry,
u32 *fid, int buflen)
{ {
struct ovl_fh *fh = NULL; struct ovl_fh *fh = NULL;
int err, enc_lower; int err, enc_lower;
...@@ -226,7 +227,7 @@ static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen) ...@@ -226,7 +227,7 @@ static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen)
goto fail; goto fail;
/* Encode an upper or lower file handle */ /* Encode an upper or lower file handle */
fh = ovl_encode_real_fh(enc_lower ? ovl_dentry_lower(dentry) : fh = ovl_encode_real_fh(ofs, enc_lower ? ovl_dentry_lower(dentry) :
ovl_dentry_upper(dentry), !enc_lower); ovl_dentry_upper(dentry), !enc_lower);
if (IS_ERR(fh)) if (IS_ERR(fh))
return PTR_ERR(fh); return PTR_ERR(fh);
...@@ -249,6 +250,7 @@ static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen) ...@@ -249,6 +250,7 @@ static int ovl_dentry_to_fid(struct dentry *dentry, u32 *fid, int buflen)
static int ovl_encode_fh(struct inode *inode, u32 *fid, int *max_len, static int ovl_encode_fh(struct inode *inode, u32 *fid, int *max_len,
struct inode *parent) struct inode *parent)
{ {
struct ovl_fs *ofs = OVL_FS(inode->i_sb);
struct dentry *dentry; struct dentry *dentry;
int bytes, buflen = *max_len << 2; int bytes, buflen = *max_len << 2;
...@@ -260,7 +262,7 @@ static int ovl_encode_fh(struct inode *inode, u32 *fid, int *max_len, ...@@ -260,7 +262,7 @@ static int ovl_encode_fh(struct inode *inode, u32 *fid, int *max_len,
if (WARN_ON(!dentry)) if (WARN_ON(!dentry))
return FILEID_INVALID; return FILEID_INVALID;
bytes = ovl_dentry_to_fid(dentry, fid, buflen); bytes = ovl_dentry_to_fid(ofs, dentry, fid, buflen);
dput(dentry); dput(dentry);
if (bytes <= 0) if (bytes <= 0)
return FILEID_INVALID; return FILEID_INVALID;
...@@ -680,7 +682,7 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, ...@@ -680,7 +682,7 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb,
if (!ovl_upper_mnt(ofs)) if (!ovl_upper_mnt(ofs))
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
upper = ovl_decode_real_fh(fh, ovl_upper_mnt(ofs), true); upper = ovl_decode_real_fh(ofs, fh, ovl_upper_mnt(ofs), true);
if (IS_ERR_OR_NULL(upper)) if (IS_ERR_OR_NULL(upper))
return upper; return upper;
......
...@@ -150,8 +150,8 @@ static struct ovl_fh *ovl_get_fh(struct ovl_fs *ofs, struct dentry *dentry, ...@@ -150,8 +150,8 @@ static struct ovl_fh *ovl_get_fh(struct ovl_fs *ofs, struct dentry *dentry,
goto out; goto out;
} }
struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt, struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
bool connected) struct vfsmount *mnt, bool connected)
{ {
struct dentry *real; struct dentry *real;
int bytes; int bytes;
...@@ -354,7 +354,7 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected, ...@@ -354,7 +354,7 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
ofs->layers[i].fs->bad_uuid) ofs->layers[i].fs->bad_uuid)
continue; continue;
origin = ovl_decode_real_fh(fh, ofs->layers[i].mnt, origin = ovl_decode_real_fh(ofs, fh, ofs->layers[i].mnt,
connected); connected);
if (origin) if (origin)
break; break;
...@@ -450,7 +450,7 @@ int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry, ...@@ -450,7 +450,7 @@ int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry,
struct ovl_fh *fh; struct ovl_fh *fh;
int err; int err;
fh = ovl_encode_real_fh(real, is_upper); fh = ovl_encode_real_fh(ofs, real, is_upper);
err = PTR_ERR(fh); err = PTR_ERR(fh);
if (IS_ERR(fh)) { if (IS_ERR(fh)) {
fh = NULL; fh = NULL;
...@@ -488,7 +488,7 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index) ...@@ -488,7 +488,7 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
if (IS_ERR_OR_NULL(fh)) if (IS_ERR_OR_NULL(fh))
return ERR_CAST(fh); return ERR_CAST(fh);
upper = ovl_decode_real_fh(fh, ovl_upper_mnt(ofs), true); upper = ovl_decode_real_fh(ofs, fh, ovl_upper_mnt(ofs), true);
kfree(fh); kfree(fh);
if (IS_ERR_OR_NULL(upper)) if (IS_ERR_OR_NULL(upper))
...@@ -640,12 +640,13 @@ static int ovl_get_index_name_fh(struct ovl_fh *fh, struct qstr *name) ...@@ -640,12 +640,13 @@ static int ovl_get_index_name_fh(struct ovl_fh *fh, struct qstr *name)
* index dir was cleared. Either way, that index cannot be used to indentify * index dir was cleared. Either way, that index cannot be used to indentify
* the overlay inode. * the overlay inode.
*/ */
int ovl_get_index_name(struct dentry *origin, struct qstr *name) int ovl_get_index_name(struct ovl_fs *ofs, struct dentry *origin,
struct qstr *name)
{ {
struct ovl_fh *fh; struct ovl_fh *fh;
int err; int err;
fh = ovl_encode_real_fh(origin, false); fh = ovl_encode_real_fh(ofs, origin, false);
if (IS_ERR(fh)) if (IS_ERR(fh))
return PTR_ERR(fh); return PTR_ERR(fh);
...@@ -694,7 +695,7 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper, ...@@ -694,7 +695,7 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper,
bool is_dir = d_is_dir(origin); bool is_dir = d_is_dir(origin);
int err; int err;
err = ovl_get_index_name(origin, &name); err = ovl_get_index_name(ofs, origin, &name);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
...@@ -805,7 +806,7 @@ static int ovl_fix_origin(struct ovl_fs *ofs, struct dentry *dentry, ...@@ -805,7 +806,7 @@ static int ovl_fix_origin(struct ovl_fs *ofs, struct dentry *dentry,
if (err) if (err)
return err; return err;
err = ovl_set_origin(dentry, lower, upper); err = ovl_set_origin(ofs, dentry, lower, upper);
if (!err) if (!err)
err = ovl_set_impure(dentry->d_parent, upper->d_parent); err = ovl_set_impure(dentry->d_parent, upper->d_parent);
......
...@@ -383,8 +383,8 @@ static inline int ovl_check_fh_len(struct ovl_fh *fh, int fh_len) ...@@ -383,8 +383,8 @@ static inline int ovl_check_fh_len(struct ovl_fh *fh, int fh_len)
return ovl_check_fb_len(&fh->fb, fh_len - OVL_FH_WIRE_OFFSET); return ovl_check_fb_len(&fh->fb, fh_len - OVL_FH_WIRE_OFFSET);
} }
struct dentry *ovl_decode_real_fh(struct ovl_fh *fh, struct vfsmount *mnt, struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
bool connected); struct vfsmount *mnt, bool connected);
int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected, int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh, bool connected,
struct dentry *upperdentry, struct ovl_path **stackp); struct dentry *upperdentry, struct ovl_path **stackp);
int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry, int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry,
...@@ -392,7 +392,8 @@ int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry, ...@@ -392,7 +392,8 @@ int ovl_verify_set_fh(struct ovl_fs *ofs, struct dentry *dentry,
bool set); bool set);
struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index); struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index);
int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index); int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index);
int ovl_get_index_name(struct dentry *origin, struct qstr *name); int ovl_get_index_name(struct ovl_fs *ofs, struct dentry *origin,
struct qstr *name);
struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh); struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh);
struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper, struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper,
struct dentry *origin, bool verify); struct dentry *origin, bool verify);
...@@ -514,9 +515,10 @@ int ovl_maybe_copy_up(struct dentry *dentry, int flags); ...@@ -514,9 +515,10 @@ int ovl_maybe_copy_up(struct dentry *dentry, int flags);
int ovl_copy_xattr(struct super_block *sb, struct dentry *old, int ovl_copy_xattr(struct super_block *sb, struct dentry *old,
struct dentry *new); struct dentry *new);
int ovl_set_attr(struct dentry *upper, struct kstat *stat); int ovl_set_attr(struct dentry *upper, struct kstat *stat);
struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper); struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct dentry *real,
int ovl_set_origin(struct dentry *dentry, struct dentry *lower, bool is_upper);
struct dentry *upper); int ovl_set_origin(struct ovl_fs *ofs, struct dentry *dentry,
struct dentry *lower, struct dentry *upper);
/* export.c */ /* export.c */
extern const struct export_operations ovl_export_operations; extern const struct export_operations ovl_export_operations;
...@@ -716,6 +716,7 @@ bool ovl_need_index(struct dentry *dentry) ...@@ -716,6 +716,7 @@ bool ovl_need_index(struct dentry *dentry)
/* Caller must hold OVL_I(inode)->lock */ /* Caller must hold OVL_I(inode)->lock */
static void ovl_cleanup_index(struct dentry *dentry) static void ovl_cleanup_index(struct dentry *dentry)
{ {
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
struct dentry *indexdir = ovl_indexdir(dentry->d_sb); struct dentry *indexdir = ovl_indexdir(dentry->d_sb);
struct inode *dir = indexdir->d_inode; struct inode *dir = indexdir->d_inode;
struct dentry *lowerdentry = ovl_dentry_lower(dentry); struct dentry *lowerdentry = ovl_dentry_lower(dentry);
...@@ -725,7 +726,7 @@ static void ovl_cleanup_index(struct dentry *dentry) ...@@ -725,7 +726,7 @@ static void ovl_cleanup_index(struct dentry *dentry)
struct qstr name = { }; struct qstr name = { };
int err; int err;
err = ovl_get_index_name(lowerdentry, &name); err = ovl_get_index_name(ofs, lowerdentry, &name);
if (err) if (err)
goto fail; goto fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment