Whamcloud - gitweb
LU-13335 ldiskfs: add projid to debug logs
[fs/lustre-release.git] / lustre / llite / file.c
index 1912240..73c256c 100644 (file)
@@ -46,7 +46,6 @@
 #include <linux/ktime.h>
 
 #include <uapi/linux/lustre/lustre_ioctl.h>
-#include <uapi/linux/llcrypt.h>
 #include <lustre_swab.h>
 
 #include "cl_object.h"
@@ -595,7 +594,7 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req)
                        put_page(vmpage);
                        break;
                }
-               cl_page_export(env, page, 1);
+               SetPageUptodate(vmpage);
                cl_page_put(env, page);
                unlock_page(vmpage);
                put_page(vmpage);
@@ -1578,6 +1577,12 @@ void ll_io_init(struct cl_io *io, struct file *file, enum cl_io_type iot,
 #endif
        }
 
+#ifdef IOCB_NOWAIT
+       io->ci_iocb_nowait = !!(args &&
+                               (args->u.normal.via_iocb->ki_flags &
+                                IOCB_NOWAIT));
+#endif
+
        io->ci_obj = ll_i2info(inode)->lli_clob;
        io->ci_lockreq = CILR_MAYBE;
        if (ll_file_nolock(file)) {
@@ -1664,6 +1669,8 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
 
        io = vvp_env_thread_io(env);
        if (file->f_flags & O_DIRECT) {
+               if (file->f_flags & O_APPEND)
+                       dio_lock = 1;
                if (!is_sync_kiocb(args->u.normal.via_iocb))
                        is_aio = true;
 
@@ -2000,6 +2007,12 @@ out:
                                   ktime_us_delta(ktime_get(), kstart));
        }
 
+       CDEBUG(D_IOTRACE,
+              "COMPLETED: file %s:"DFID", ppos: %lld, count: %zu\n",
+              file_dentry(file)->d_name.name,
+              PFID(ll_inode2fid(file_inode(file))), iocb->ki_pos,
+              iov_iter_count(to));
+
        RETURN(result);
 }
 
@@ -2143,6 +2156,12 @@ out:
                                   ktime_us_delta(ktime_get(), kstart));
        }
 
+       CDEBUG(D_IOTRACE,
+              "COMPLETED: file %s:"DFID", ppos: %lld, count: %zu\n",
+              file_dentry(file)->d_name.name,
+              PFID(ll_inode2fid(file_inode(file))), iocb->ki_pos,
+              iov_iter_count(from));
+
        RETURN(rc_normal);
 }
 
@@ -2755,7 +2774,7 @@ static int ll_do_fiemap(struct inode *inode, struct fiemap *fiemap,
                        GOTO(out, rc);
        }
 
-       fmkey.lfik_oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+       fmkey.lfik_oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLPROJID;
        obdo_from_inode(&fmkey.lfik_oa, inode, OBD_MD_FLSIZE);
        obdo_set_parent_fid(&fmkey.lfik_oa, &ll_i2info(inode)->lli_fid);
 
@@ -3496,12 +3515,14 @@ int ll_ioctl_check_project(struct inode *inode, __u32 xflags,
 
 static int ll_set_project(struct inode *inode, __u32 xflags, __u32 projid)
 {
-       struct md_op_data *op_data;
        struct ptlrpc_request *req = NULL;
+       struct md_op_data *op_data;
        struct cl_object *obj;
        unsigned int inode_flags;
        int rc = 0;
 
+       CDEBUG(D_QUOTA, DFID" xflags=%x projid=%u\n",
+              PFID(ll_inode2fid(inode)), xflags, projid);
        rc = ll_ioctl_check_project(inode, xflags, projid);
        if (rc)
                RETURN(rc);
@@ -3515,7 +3536,10 @@ static int ll_set_project(struct inode *inode, __u32 xflags, __u32 projid)
        op_data->op_attr_flags = ll_inode_to_ext_flags(inode_flags);
        if (xflags & FS_XFLAG_PROJINHERIT)
                op_data->op_attr_flags |= LUSTRE_PROJINHERIT_FL;
+
+       /* pass projid to md_op_data */
        op_data->op_projid = projid;
+
        op_data->op_xvalid |= OP_XVALID_PROJID | OP_XVALID_FLAGS;
        rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL, 0, &req);
        ptlrpc_req_finished(req);
@@ -4844,7 +4868,6 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
        __u64 data_version = 0;
        size_t namelen = strlen(name);
        int lumlen = lmv_user_md_size(lum->lum_stripe_count, lum->lum_magic);
-       bool oldformat = false;
        int rc;
        ENTRY;
 
@@ -4895,20 +4918,6 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
        if (is_root_inode(child_inode))
                GOTO(out_iput, rc = -EINVAL);
 
-       if (IS_ENCRYPTED(parent)) {
-               if (unlikely(!llcrypt_policy_has_filename_enc(parent)))
-                       oldformat = true;
-       } else if (IS_ENCRYPTED(child_inode) &&
-                  unlikely(!llcrypt_policy_has_filename_enc(child_inode))) {
-               oldformat = true;
-       }
-       if (unlikely(oldformat)) {
-               CDEBUG(D_SEC,
-                      "cannot migrate old format encrypted "DFID", please move to new enc dir first\n",
-                      PFID(ll_inode2fid(child_inode)));
-               GOTO(out_iput, rc = -EUCLEAN);
-       }
-
        op_data = ll_prep_md_op_data(NULL, parent, NULL, name, namelen,
                                     child_inode->i_mode, LUSTRE_OPC_ANY, NULL);
        if (IS_ERR(op_data))
@@ -5183,12 +5192,14 @@ static int ll_merge_md_attr(struct inode *inode)
        struct cl_attr attr = { 0 };
        int rc;
 
-       LASSERT(lli->lli_lsm_md != NULL);
-
-       if (!lmv_dir_striped(lli->lli_lsm_md))
+       if (!lli->lli_lsm_md)
                RETURN(0);
 
        down_read(&lli->lli_lsm_sem);
+       if (!lmv_dir_striped(lli->lli_lsm_md)) {
+               up_read(&lli->lli_lsm_sem);
+               RETURN(0);
+       }
        rc = md_merge_attr(ll_i2mdexp(inode), ll_i2info(inode)->lli_lsm_md,
                           &attr, ll_md_blocking_ast);
        up_read(&lli->lli_lsm_sem);
@@ -5382,11 +5393,11 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat)
 int cl_falloc(struct file *file, struct inode *inode, int mode, loff_t offset,
              loff_t len)
 {
+       loff_t size = i_size_read(inode);
        struct lu_env *env;
        struct cl_io *io;
        __u16 refcheck;
        int rc;
-       loff_t size = i_size_read(inode);
 
        ENTRY;
 
@@ -5405,12 +5416,14 @@ int cl_falloc(struct file *file, struct inode *inode, int mode, loff_t offset,
        io->u.ci_setattr.sa_falloc_end = offset + len;
        io->u.ci_setattr.sa_subtype = CL_SETATTR_FALLOCATE;
 
-       CDEBUG(D_INODE, "UID %u GID %u\n",
+       CDEBUG(D_INODE, "UID %u GID %u PRJID %u\n",
               from_kuid(&init_user_ns, inode->i_uid),
-              from_kgid(&init_user_ns, inode->i_gid));
+              from_kgid(&init_user_ns, inode->i_gid),
+              ll_i2info(inode)->lli_projid);
 
        io->u.ci_setattr.sa_falloc_uid = from_kuid(&init_user_ns, inode->i_uid);
        io->u.ci_setattr.sa_falloc_gid = from_kgid(&init_user_ns, inode->i_gid);
+       io->u.ci_setattr.sa_falloc_projid = ll_i2info(inode)->lli_projid;
 
        if (io->u.ci_setattr.sa_falloc_end > size) {
                loff_t newsize = io->u.ci_setattr.sa_falloc_end;