#include <linux/backing-dev.h>
#include <linux/posix_acl_xattr.h>
+#ifndef HAVE_FILE_DENTRY
+static inline struct dentry *file_dentry(const struct file *file)
+{
+ return file->f_path.dentry;
+}
+#endif
+
+#ifndef HAVE_FILE_INODE
+static inline struct inode *file_inode(const struct file *file)
+{
+ return file->f_path.dentry->d_inode;
+}
+#endif
+
#if defined(HAVE_FILE_FSYNC_4ARGS) || defined(HAVE_FILE_FSYNC_2ARGS)
#define ll_vfs_fsync_range(fp, start, end, datasync) \
vfs_fsync_range(fp, start, end, datasync)
#else
#define ll_vfs_fsync_range(fp, start, end, datasync) \
- vfs_fsync_range(fp, (fp)->f_path.dentry, start, end, datasync)
+ vfs_fsync_range(fp, file_dentry(fp), start, end, datasync)
#endif
#define flock_type(fl) ((fl)->fl_type)
set_fs(get_ds());
list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) {
- struct dentry *de = filp->f_path.dentry;
+ struct dentry *de = file_dentry(filp);
static loff_t f_pos;
__LASSERT_TAGE_INVARIANT(tage);
]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
#
+# LC_HAVE_FILE_DENTRY
+#
+# 4.5 adds wrapper file_dentry
+#
+AC_DEFUN([LC_HAVE_FILE_DENTRY], [
+LB_CHECK_COMPILE([if Linux kernel has 'file_dentry'],
+file_dentry, [
+ #include <linux/fs.h>
+],[
+ file_dentry(NULL);
+], [
+ AC_DEFINE(HAVE_FILE_DENTRY, 1,
+ [kernel has file_dentry])
+])
+]) # LC_HAVE_FILE_DENTRY
+
+#
# LC_PROG_LINUX
#
# Lustre linux kernel checks
LC_HAVE_QC_MAKE_REQUEST_FN
LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
+ # 4.5
+ LC_HAVE_FILE_DENTRY
+
#
AS_IF([test "x$enable_server" != xno], [
LC_FUNC_DEV_SET_RDONLY
static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
#endif
{
- struct inode *inode = filp->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(filp);
struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp);
struct ll_sb_info *sbi = ll_i2sbi(inode);
int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH;
if (unlikely(op_data->op_mea1 != NULL)) {
/* This is only needed for striped dir to fill ..,
* see lmv_read_entry */
- if (filp->f_path.dentry->d_parent != NULL &&
- filp->f_path.dentry->d_parent->d_inode != NULL) {
+ if (file_dentry(filp)->d_parent != NULL &&
+ file_dentry(filp)->d_parent->d_inode != NULL) {
__u64 ibits = MDS_INODELOCK_UPDATE;
struct inode *parent =
- filp->f_path.dentry->d_parent->d_inode;
+ file_dentry(filp)->d_parent->d_inode;
if (ll_have_md_lock(parent, &ibits, LCK_MINMODE))
op_data->op_fid3 = *ll_inode2fid(parent);
static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct obd_ioctl_data *data;
int rc = 0;
RETURN(-EFAULT);
}
- if (inode->i_sb->s_root == file->f_path.dentry)
+ if (inode->i_sb->s_root == file_dentry(file))
set_default = 1;
/* in v1 and v3 cases lumv1 points to data */
CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
PFID(ll_inode2fid(inode)), inode);
- if (inode->i_sb->s_root != file->f_path.dentry)
+ if (inode->i_sb->s_root != file_dentry(file))
ll_stats_ops_tally(sbi, LPROC_LL_RELEASE, 1);
fd = LUSTRE_FPRIVATE(file);
LASSERT(fd != NULL);
if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd)
ll_deauthorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file->f_path.dentry) {
+ if (inode->i_sb->s_root == file_dentry(file)) {
LUSTRE_FPRIVATE(file) = NULL;
ll_file_data_put(fd);
RETURN(0);
static int ll_intent_file_open(struct file *file, void *lmm, int lmmsize,
struct lookup_intent *itp)
{
- struct dentry *de = file->f_path.dentry;
+ struct dentry *de = file_dentry(file);
struct ll_sb_info *sbi = ll_i2sbi(de->d_inode);
struct dentry *parent = de->d_parent;
const char *name = NULL;
static int ll_local_open(struct file *file, struct lookup_intent *it,
struct ll_file_data *fd, struct obd_client_handle *och)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
ENTRY;
LASSERT(!LUSTRE_FPRIVATE(file));
if (S_ISDIR(inode->i_mode))
ll_authorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file->f_path.dentry) {
+ if (inode->i_sb->s_root == file_dentry(file)) {
LUSTRE_FPRIVATE(file) = fd;
RETURN(0);
}
GOTO(out_openerr, rc);
}
- ll_release_openhandle(file->f_path.dentry, it);
+ ll_release_openhandle(file_dentry(file), it);
}
(*och_usecount)++;
static bool file_is_noatime(const struct file *file)
{
const struct vfsmount *mnt = file->f_path.mnt;
- const struct inode *inode = file->f_path.dentry->d_inode;
+ const struct inode *inode = file_inode((struct file *)file);
/* Adapted from file_accessed() and touch_atime().*/
if (file->f_flags & O_NOATIME)
static void ll_io_init(struct cl_io *io, const struct file *file, int write)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode((struct file *)file);
io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
if (write) {
loff_t *ppos, size_t count)
{
struct vvp_io *vio = vvp_env_io(env);
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
struct cl_io *io;
ENTRY;
CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: "LPU64", count: %zu\n",
- file->f_path.dentry->d_name.name, iot, *ppos, count);
+ file_dentry(file)->d_name.name, iot, *ppos, count);
restart:
io = vvp_env_thread_io(env);
if ((rc == 0 || rc == -ENODATA) && count > 0 && io->ci_need_restart) {
CDEBUG(D_VFSTRACE,
"%s: restart %s from %lld, count:%zu, result: %zd\n",
- file->f_path.dentry->d_name.name,
+ file_dentry(file)->d_name.name,
iot == CIT_READ ? "read" : "write",
*ppos, count, result);
goto restart;
if (rc < 0)
GOTO(out_unlock, rc);
- ll_release_openhandle(file->f_path.dentry, &oit);
+ ll_release_openhandle(file_dentry(file), &oit);
out_unlock:
ll_inode_size_unlock(inode);
if (llss == NULL)
RETURN(-ENOMEM);
- llss->inode1 = file1->f_path.dentry->d_inode;
- llss->inode2 = file2->f_path.dentry->d_inode;
+ llss->inode1 = file_inode(file1);
+ llss->inode2 = file_inode(file2);
rc = ll_check_swap_layouts_validity(llss->inode1, llss->inode2);
if (rc < 0)
mutex_lock(&inode->i_mutex);
- rc = ll_setattr_raw(file->f_path.dentry, attr, true);
+ rc = ll_setattr_raw(file_dentry(file), attr, true);
if (rc == -ENODATA)
rc = 0;
static int ll_file_futimes_3(struct file *file, const struct ll_futimes_3 *lfu)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct iattr ia = {
.ia_valid = ATTR_ATIME | ATTR_ATIME_SET |
ATTR_MTIME | ATTR_MTIME_SET |
RETURN(-EINVAL);
mutex_lock(&inode->i_mutex);
- rc = ll_setattr_raw(file->f_path.dentry, &ia, false);
+ rc = ll_setattr_raw(file_dentry(file), &ia, false);
mutex_unlock(&inode->i_mutex);
RETURN(rc);
static long
ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
int flags, rc;
ENTRY;
mutex_unlock(&lli->lli_och_mutex);
if (och == NULL)
GOTO(out, rc = -ENOLCK);
- inode2 = file2->f_path.dentry->d_inode;
+ inode2 = file_inode(file2);
rc = ll_swap_layouts_close(och, inode, inode2);
} else {
rc = ll_swap_layouts(file, file2, &lsl);
generic_file_llseek_size(struct file *file, loff_t offset, int origin,
loff_t maxsize, loff_t eof)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
switch (origin) {
case SEEK_END:
static loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
loff_t retval, eof = 0;
ENTRY;
static int ll_flush(struct file *file, fl_owner_t id)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
int rc, err;
}
/*
- * When dentry is provided (the 'else' case), *file->f_path.dentry may be
+ * When dentry is provided (the 'else' case), file_dentry() may be
* null and dentry must be used directly rather than pulled from
- * *file->f_path.dentry as is done otherwise.
+ * file_dentry() as is done otherwise.
*/
#ifdef HAVE_FILE_FSYNC_4ARGS
int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
- struct dentry *dentry = file->f_path.dentry;
+ struct dentry *dentry = file_dentry(file);
#elif defined(HAVE_FILE_FSYNC_2ARGS)
int ll_fsync(struct file *file, int datasync)
{
- struct dentry *dentry = file->f_path.dentry;
+ struct dentry *dentry = file_dentry(file);
loff_t start = 0;
loff_t end = LLONG_MAX;
#else
static int
ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ldlm_enqueue_info einfo = {
.ei_type = LDLM_FLOCK,
qstr.hash = full_name_hash(name, namelen);
qstr.name = name;
qstr.len = namelen;
- dchild = d_lookup(file->f_path.dentry, &qstr);
+ dchild = d_lookup(file_dentry(file), &qstr);
if (dchild != NULL) {
if (dchild->d_inode != NULL)
child_inode = igrab(dchild->d_inode);
static inline int ll_file_nolock(const struct file *file)
{
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode((struct file *)file);
LASSERT(fd != NULL);
return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) ||
u64 cl_fid_build_ino(const struct lu_fid *fid, int api32);
u32 cl_fid_build_gen(const struct lu_fid *fid);
-#ifndef HAVE_FILE_INODE
-static inline struct inode *file_inode(struct file *file)
-{
- return file->f_path.dentry->d_inode;
-}
-#endif
-
#ifndef HAVE_IOV_ITER_TRUNCATE
static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
{
*/
int ll_getparent(struct file *file, struct getparent __user *arg)
{
- struct dentry *dentry = file->f_path.dentry;
- struct inode *inode = dentry->d_inode;
+ struct dentry *dentry = file_dentry(file);
+ struct inode *inode = file_inode(file);
struct linkea_data *ldata;
struct lu_buf buf = LU_BUF_NULL;
struct lu_name ln;
pgoff_t index, unsigned long *ra_flags)
{
struct file *file = vma->vm_file;
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct cl_io *io;
struct cl_fault_io *fio;
int rc;
result = ll_page_mkwrite0(vma, vmf->page, &retry);
if (!printed && ++count > 16) {
- const struct dentry *de = vma->vm_file->f_path.dentry;
+ const struct dentry *de = file_dentry(vma->vm_file);
CWARN("app(%s): the page %lu of file "DFID" is under"
" heavy contention\n",
*/
static void ll_vm_open(struct vm_area_struct * vma)
{
- struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(vma->vm_file);
struct vvp_object *vob = cl_inode2vvp(inode);
ENTRY;
*/
static void ll_vm_close(struct vm_area_struct *vma)
{
- struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(vma->vm_file);
struct vvp_object *vob = cl_inode2vvp(inode);
ENTRY;
int ll_file_mmap(struct file *file, struct vm_area_struct * vma)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
int rc;
ENTRY;
{
const struct lu_env *env = lo->lo_env;
struct cl_io *io = &lo->lo_io;
- struct dentry *de = lo->lo_backing_file->f_path.dentry;
+ struct dentry *de = file_dentry(lo->lo_backing_file);
struct inode *inode = de->d_inode;
struct cl_object *obj = ll_i2info(inode)->lli_clob;
pgoff_t offset;
err = -ENOENT;
break;
}
- inode = lo->lo_backing_file->f_path.dentry->d_inode;
+ inode = file_inode(lo->lo_backing_file);
if (inode != NULL && lo->lo_state == LLOOP_BOUND)
fid = ll_i2info(inode)->lli_fid;
else
mutex_lock(&lloop_mutex);
switch (cmd) {
case LL_IOC_LLOOP_ATTACH: {
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct lloop_device *lo_free = NULL;
int i;
lo_free = lo;
continue;
}
- if (lo->lo_backing_file->f_path.dentry->d_inode ==
- inode)
+ if (file_inode(lo->lo_backing_file) == inode)
break;
}
if (lo || !lo_free)
int ll_readpage(struct file *file, struct page *vmpage)
{
- struct inode *inode = file->f_path.dentry->d_inode;
+ struct inode *inode = file_inode(file);
struct cl_object *clob = ll_i2info(inode)->lli_clob;
struct ll_cl_context *lcc;
const struct lu_env *env;
unplug = true;
}
if (unplug ||
- file->f_flags & O_SYNC || IS_SYNC(file->f_path.dentry->d_inode))
+ file->f_flags & O_SYNC || IS_SYNC(file_inode(file)))
result = vvp_io_write_commit(env, io);
if (result < 0)
struct vvp_io *vio = cl2vvp_io(env, ios);
struct inode *inode = vvp_object_inode(ios->cis_obj);
- LASSERT(inode == vio->vui_fd->fd_file->f_path.dentry->d_inode);
+ LASSERT(inode == file_inode(vio->vui_fd->fd_file));
vio->u.fault.ft_mtime = LTIME_S(inode->i_mtime);
return 0;
down_read(&mm->mmap_sem);
while((vma = our_vma(mm, addr, count)) != NULL) {
- struct dentry *de = vma->vm_file->f_path.dentry;
+ struct dentry *de = file_dentry(vma->vm_file);
struct inode *inode = de->d_inode;
int flags = CEF_MUST;
int lprocfs_evict_client_open(struct inode *inode, struct file *f)
{
- struct obd_device *obd = PDE_DATA(f->f_path.dentry->d_inode);
+ struct obd_device *obd = PDE_DATA(file_inode(f));
atomic_inc(&obd->obd_evict_inprogress);
return 0;
int lprocfs_evict_client_release(struct inode *inode, struct file *f)
{
- struct obd_device *obd = PDE_DATA(f->f_path.dentry->d_inode);
+ struct obd_device *obd = PDE_DATA(file_inode(f));
atomic_dec(&obd->obd_evict_inprogress);
wake_up(&obd->obd_evict_inprogress_waitq);
RETURN(PTR_ERR(filp));
}
- inode = filp->f_path.dentry->d_inode;
+ inode = file_inode(filp);
/* 'What the @fid is' is not imporatant, because the object
* has no OI mapping, and only is visible inside the OSD.*/
lu_igif_build(fid, inode->i_ino, inode->i_generation);
static
ssize_t gss_pipe_downcall(struct file *filp, const char *src, size_t mlen)
{
- struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode);
+ struct rpc_inode *rpci = RPC_I(file_inode(filp));
struct gss_upcall_msg *gss_msg;
struct ptlrpc_cli_ctx *ctx;
struct gss_cli_ctx *gctx = NULL;