Commit 51a7f431 authored by J. R. Okajima's avatar J. R. Okajima
Browse files

aufs: atomic_open 3/5, pass h_file to au_do_open()



Extend do_open_dir(), au_do_open_nondir() and au_do_open() to receive an
additional parameter h_file, which is an opened file object by branch
fs's ->atomic_open(). By this design/commit, aufs doesn't have to
duplicate many codes into a new aufs_atomic_open() (in later commit),
and can simply share them.
Signed-off-by: default avatarJ. R. Okajima <hooanon05g@gmail.com>
parent be3f6e60
...@@ -13,11 +13,10 @@ ...@@ -13,11 +13,10 @@
#include <linux/security.h> #include <linux/security.h>
#include "aufs.h" #include "aufs.h"
int au_do_open_nondir(struct file *file, int flags) int au_do_open_nondir(struct file *file, int flags, struct file *h_file)
{ {
int err; int err;
aufs_bindex_t bindex; aufs_bindex_t bindex;
struct file *h_file;
struct dentry *dentry; struct dentry *dentry;
struct au_finfo *finfo; struct au_finfo *finfo;
struct inode *h_inode; struct inode *h_inode;
...@@ -26,11 +25,15 @@ int au_do_open_nondir(struct file *file, int flags) ...@@ -26,11 +25,15 @@ int au_do_open_nondir(struct file *file, int flags)
err = 0; err = 0;
dentry = file->f_path.dentry; dentry = file->f_path.dentry;
AuDebugOn(IS_ERR_OR_NULL(dentry));
finfo = au_fi(file); finfo = au_fi(file);
memset(&finfo->fi_htop, 0, sizeof(finfo->fi_htop)); memset(&finfo->fi_htop, 0, sizeof(finfo->fi_htop));
atomic_set(&finfo->fi_mmapped, 0); atomic_set(&finfo->fi_mmapped, 0);
bindex = au_dbtop(dentry); bindex = au_dbtop(dentry);
if (!h_file)
h_file = au_h_open(dentry, bindex, flags, file); h_file = au_h_open(dentry, bindex, flags, file);
else
get_file(h_file);
if (IS_ERR(h_file)) if (IS_ERR(h_file))
err = PTR_ERR(h_file); err = PTR_ERR(h_file);
else { else {
......
...@@ -84,21 +84,41 @@ out: ...@@ -84,21 +84,41 @@ out:
int au_do_open(struct file *file, struct au_do_open_args *args) int au_do_open(struct file *file, struct au_do_open_args *args)
{ {
int err; int err, aopen = args->aopen;
struct dentry *dentry; struct dentry *dentry;
struct au_finfo *finfo; struct au_finfo *finfo;
if (!aopen)
err = au_finfo_init(file, args->fidir);
else {
lockdep_off();
err = au_finfo_init(file, args->fidir); err = au_finfo_init(file, args->fidir);
lockdep_on();
}
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
dentry = file->f_path.dentry; dentry = file->f_path.dentry;
AuDebugOn(IS_ERR_OR_NULL(dentry));
di_read_lock_child(dentry, AuLock_IR); di_read_lock_child(dentry, AuLock_IR);
err = args->open(file, vfsub_file_flags(file)); if (!aopen)
err = args->open(file, vfsub_file_flags(file), NULL);
else {
lockdep_off();
err = args->open(file, vfsub_file_flags(file),
args->h_file);
lockdep_on();
}
di_read_unlock(dentry, AuLock_IR); di_read_unlock(dentry, AuLock_IR);
finfo = au_fi(file); finfo = au_fi(file);
if (!aopen)
fi_write_unlock(file);
else {
lockdep_off();
fi_write_unlock(file); fi_write_unlock(file);
lockdep_on();
}
if (unlikely(err)) { if (unlikely(err)) {
finfo->fi_hdir = NULL; finfo->fi_hdir = NULL;
au_finfo_fin(file); au_finfo_fin(file);
......
...@@ -60,9 +60,11 @@ unsigned int au_file_roflags(unsigned int flags); ...@@ -60,9 +60,11 @@ unsigned int au_file_roflags(unsigned int flags);
struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags, struct file *au_h_open(struct dentry *dentry, aufs_bindex_t bindex, int flags,
struct file *file); struct file *file);
struct au_do_open_args { struct au_do_open_args {
int (*open)(struct file *file, int flags); int aopen;
int (*open)(struct file *file, int flags,
struct file *h_file);
struct au_fidir *fidir; struct au_fidir *fidir;
/* add more later */ struct file *h_file;
}; };
int au_do_open(struct file *file, struct au_do_open_args *args); int au_do_open(struct file *file, struct au_do_open_args *args);
int au_reopen_nondir(struct file *file); int au_reopen_nondir(struct file *file);
...@@ -75,7 +77,7 @@ int au_do_flush(struct file *file, fl_owner_t id, ...@@ -75,7 +77,7 @@ int au_do_flush(struct file *file, fl_owner_t id,
/* f_op.c */ /* f_op.c */
extern const struct file_operations aufs_file_fop; extern const struct file_operations aufs_file_fop;
int au_do_open_nondir(struct file *file, int flags); int au_do_open_nondir(struct file *file, int flags, struct file *h_file);
int aufs_release_nondir(struct inode *inode __maybe_unused, struct file *file); int aufs_release_nondir(struct inode *inode __maybe_unused, struct file *file);
struct file *au_read_pre(struct file *file, int keep_fi, unsigned int lsc); struct file *au_read_pre(struct file *file, int keep_fi, unsigned int lsc);
......
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