Whamcloud - gitweb
LU-4017 quota: cleanup to improve quota codes 77/26577/8
authorWang Shilong <wshilong@ddn.com>
Thu, 13 Apr 2017 02:45:10 +0000 (22:45 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 May 2017 03:44:28 +0000 (03:44 +0000)
Add man page updates for project quota, also
cleanup to address some style and minor problems

Change-Id: I3ee3e866dd0300a1b07e0f5319dfd695c0bafba0
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/26577
Tested-by: Jenkins
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
27 files changed:
lustre/contrib/wireshark/packet-lustre.c
lustre/doc/lfs.1
lustre/include/cl_object.h
lustre/include/lu_object.h
lustre/include/lustre/lustre_idl.h
lustre/include/lustre/lustre_user.h
lustre/include/lustre_quota.h
lustre/include/obd.h
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/lod/lod_object.c
lustre/mdt/mdt_reint.c
lustre/obdclass/llog_swab.c
lustre/ofd/ofd_io.c
lustre/osc/osc_request.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c
lustre/osd-ldiskfs/osd_quota.c
lustre/osd-zfs/osd_oi.c
lustre/ptlrpc/pack_generic.c
lustre/quota/lquota_internal.h
lustre/quota/lquota_lib.c
lustre/quota/qsd_lib.c
lustre/utils/lfs.c

index 65ca314..b8397e7 100644 (file)
@@ -9910,7 +9910,7 @@ void proto_register_dcerpc_lustre(void)
     { &hf_lustre_mdt_rec_setattr_sa_padding_2,
       { "Sa Padding 2", "lustre.mdt_rec_setattr.sa_padding_2", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
     { &hf_lustre_mdt_rec_setattr_sa_projid,
-      { "Sa Padding 3", "lustre.mdt_rec_setattr.sa_projid", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
+      { "Sa Projid", "lustre.mdt_rec_setattr.sa_projid", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
     { &hf_lustre_mdt_rec_setattr_sa_padding_4,
       { "Sa Padding 4", "lustre.mdt_rec_setattr.sa_padding_4", FT_UINT32, BASE_DEC, NULL, 0, "", HFILL }},
     { &hf_lustre_mdt_rec_setattr_sa_padding_5,
index 27c4657..852f574 100644 (file)
@@ -31,7 +31,7 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
         \fB[[!] --component-end|-E [+-]N[kMGTPE]]
         \fB[[!] --component-flags <comp_flags>]
         \fB[--type |-t {bcdflpsD}] [[!] --gid|-g|--group|-G <gname>|<gid>]
-        \fB[[!] --uid|-u|--user|-U <uname>|<uid>] [[!] --pool <pool>]\fR
+        \fB[[!] --uid|-u|--user|-U|--projid <uname>|<uid>|<projid>] [[!] --pool <pool>]\fR
 .br
 .B lfs getname [-h]|[path ...]
 .br
@@ -77,9 +77,9 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
 .br
 .B lfs pool_list <filesystem>[.<pool>] | <pathname>
 .br
-.B lfs quota [-q] [-v] [-o obd_uuid|-I ost_idx|-i mdt_idx] [-u <uname>| -u <uid>|-g <gname>| -g <gid>] <filesystem>
+.B lfs quota [-q] [-v] [-o obd_uuid|-I ost_idx|-i mdt_idx] [-u <uname>| -u <uid>|-g <gname>| -g <gid>] [-p <projid>] <filesystem>
 .br
-.B lfs quota -t <-u|-g> <filesystem>
+.B lfs quota -t <-u|-g|-p> <filesystem>
 .br
 .B lfs quotacheck [-ug] <filesystem>
 .br
@@ -87,24 +87,24 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
 .br
 .B lfs quotaoff [-ug] <filesystem>
 .br
-.B lfs setquota <-u|--user|-g|--group> <uname|uid|gname|gid>
+.B lfs setquota <-u|--user|-g|--group|-p|--projid> <uname|uid|gname|gid|projid>
              \fB[--block-softlimit <block-softlimit>]
              \fB[--block-hardlimit <block-hardlimit>]
              \fB[--inode-softlimit <inode-softlimit>]
              \fB[--inode-hardlimit <inode-hardlimit>]
              \fB<filesystem>\fR
 .br
-.B lfs setquota <-u|--user|-g|--group> <uname|uid|gname|gid>
+.B lfs setquota <-u|--user|-g|--group|-p|--projid> <uname|uid|gname|gid|projid>
              \fB[-b <block-softlimit>] [-B <block-hardlimit>]
              \fB[-i <inode-softlimit>] [-I <inode-hardlimit>]
              \fB<filesystem>\fR
 .br
-.B lfs setquota -t <-u|-g>
+.B lfs setquota -t <-u|-g|-p>
              \fB[--block-grace <block-grace>]\fR
              \fB[--inode-grace <inode-grace>]\fR
              \fB<filesystem>\fR
 .br
-.B lfs setquota -t <-u|-g>
+.B lfs setquota -t <-u|-g|-p>
              \fB[-b <block-grace>] [-i <inode-grace>]\fR
              \fB<filesystem>\fR
 .br
@@ -156,7 +156,7 @@ for details of
 usage.
 .TP
 .B find
-To search the directory tree rooted at the given dir/file name for the files that match the given parameters: \fB--atime\fR (file was last accessed N*24 hours ago), \fB--ctime\fR (file's status was last changed N*24 hours ago), \fB--mtime\fR (file's data was last modified N*24 hours ago), \fB--obd\fR (file has an object on a specific OST or OSTs), \fB--size\fR (file has size in bytes, or \fBk\fRilo-, \fBM\fRega-, \fBG\fRiga-, \fBT\fRera-, \fBP\fReta-, or \fBE\fRxabytes if a suffix is given), \fB--type\fR (file has the type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory, \fBp\fRipe, \fBf\fRile, sym\fBl\fRink, \fBs\fRocket, or \fBD\fRoor (Solaris)), \fB--uid\fR (file has specific numeric user ID), \fB--user\fR (file owned by specific user, numeric user ID allowed), \fB--gid\fR (file has specific group ID), \fB--group\fR (file belongs to specific group, numeric group ID allowed), \fB--layout\fR (file has a raid0 layout or is released). The option \fB--maxdepth\fR limits find to decend at most N levels of directory tree. The options \fB--print\fR and \fB--print0\fR print full file name, followed by a newline or NUL character correspondingly.  Using \fB!\fR before an option negates its meaning (\fIfiles NOT matching the parameter\fR).  Using \fB+\fR before a numeric value means \fIfiles with the parameter OR MORE\fR, while \fB-\fR before a numeric value means \fIfiles with the parameter OR LESS\fR.
+To search the directory tree rooted at the given dir/file name for the files that match the given parameters: \fB--atime\fR (file was last accessed N*24 hours ago), \fB--ctime\fR (file's status was last changed N*24 hours ago), \fB--mtime\fR (file's data was last modified N*24 hours ago), \fB--obd\fR (file has an object on a specific OST or OSTs), \fB--size\fR (file has size in bytes, or \fBk\fRilo-, \fBM\fRega-, \fBG\fRiga-, \fBT\fRera-, \fBP\fReta-, or \fBE\fRxabytes if a suffix is given), \fB--type\fR (file has the type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory, \fBp\fRipe, \fBf\fRile, sym\fBl\fRink, \fBs\fRocket, or \fBD\fRoor (Solaris)), \fB--uid\fR (file has specific numeric user ID), \fB--user\fR (file owned by specific user, numeric user ID allowed), \fB--gid\fR (file has specific group ID), \fB--group\fR (file belongs to specific group, numeric group ID allowed),\fB--projid\fR (file has specific numeric project ID), \fB--layout\fR (file has a raid0 layout or is released). The option \fB--maxdepth\fR limits find to decend at most N levels of directory tree. The options \fB--print\fR and \fB--print0\fR print full file name, followed by a newline or NUL character correspondingly.  Using \fB!\fR before an option negates its meaning (\fIfiles NOT matching the parameter\fR).  Using \fB+\fR before a numeric value means \fIfiles with the parameter OR MORE\fR, while \fB-\fR before a numeric value means \fIfiles with the parameter OR LESS\fR.
 .TP
 .B getname [-h]|[path ...]
 Report all the Lustre mount points and the corresponding Lustre filesystem
@@ -260,11 +260,11 @@ or
 or the OSTs in
 .IR filesystem.pool .
 .TP
-.B quota [-q] [-v] [-o obd_uuid|-i mdt_idx|-I ost_idx] [-u|-g <uname>|<uid>|<gname>|<gid>] <filesystem>
-To display disk usage and limits, either for the full filesystem, or for objects on a specific obd. A user or group name or an ID can be specified. If both user and group are omitted quotas for current uid/gid are shown. -v provides more verbose (with per-obd statistics) output. -q disables printing of additional descriptions (including column titles).
+.B quota [-q] [-v] [-o obd_uuid|-i mdt_idx|-I ost_idx] [-u|-g|-p <uname>|<uid>|<gname>|<gid>|<projid>] <filesystem>
+To display disk usage and limits, either for the full filesystem, or for objects on a specific obd. A user or group name or an ID can be specified. If user group and project are omitted quotas for current uid/gid/projid are shown. -v provides more verbose (with per-obd statistics) output. -q disables printing of additional descriptions (including column titles).
 .TP
-.B quota -t <-u|-g> <filesystem>
-To display block and inode grace times for user (-u) or group (-g) quotas
+.B quota -t <-u|-g|-p> <filesystem>
+To display block and inode grace times for user (-u) or group (-g) or project (-p) quotas
 .TP
 .B quotacheck [-ugf] <filesystem> (deprecated as of 2.4.0)
 To scan the specified filesystem for disk usage, and create or update quota files. Options specify quota for users (-u) groups (-g) and force (-f). Not useful anymore with servers >= 2.4.0 since space accounting is always turned on.
@@ -275,11 +275,11 @@ To turn filesystem quotas on. Options specify quota for users (-u) groups (-g) a
 .B quotaoff [-ugf] <filesystem> (deprecated as of 2.4.0)
 To turn filesystem quotas off.  Options specify quota for users (-u) groups (-g) and force (-f). Not used anymore in lustre 2.4.0 where quota enforcement can be turned off (for inode or block) by running the following command on the MGS: lctl conf_param ${FSNAME}.quota.<ost|mdt>=""
 .TP
-.B setquota  <-u|-g> <uname>|<uid>|<gname>|<gid> [--block-softlimit <block-softlimit>] [--block-hardlimit <block-hardlimit>] [--inode-softlimit <inode-softlimit>] [--inode-hardlimit <inode-hardlimit>] <filesystem>
-To set filesystem quotas for users or groups. Limits can be specified with -b, -k, -m, -g, -t, -p suffixes which specify units of 1, 2^10, 2^20, 2^30, 2^40 and 2^50 accordingly. Block limits unit is kilobyte (1024) by default and block limits are always kilobyte-grained (even if specified in bytes), see EXAMPLES
+.B setquota  <-u|-g|-p> <uname>|<uid>|<gname>|<gid>|<projid> [--block-softlimit <block-softlimit>] [--block-hardlimit <block-hardlimit>] [--inode-softlimit <inode-softlimit>] [--inode-hardlimit <inode-hardlimit>] <filesystem>
+To set filesystem quotas for users, groups or project. Limits can be specified with -b, -k, -m, -g, -t, -p suffixes which specify units of 1, 2^10, 2^20, 2^30, 2^40 and 2^50 accordingly. Block limits unit is kilobyte (1024) by default and block limits are always kilobyte-grained (even if specified in bytes), see EXAMPLES
 .TP
-.B setquota -t [-u|-g] [--block-grace <block-grace>] [--inode-grace <inode-grace>] <filesystem>
-To set filesystem quota grace times for users or groups. Grace time is specified in "XXwXXdXXhXXmXXs" format or as an integer seconds value, see EXAMPLES
+.B setquota -t [-u|-g|-p] [--block-grace <block-grace>] [--inode-grace <inode-grace>] <filesystem>
+To set filesystem quota grace times for users,groups or project. Grace time is specified in "XXwXXdXXhXXmXXs" format or as an integer seconds value, see EXAMPLES
 .TP
 .B swap_layouts <filename1> <filename2>
 Swap the data (layout and OST objects) of two regular files. The
index 66c4ddc..976c695 100644 (file)
@@ -175,13 +175,13 @@ struct cl_attr {
  * Fields in cl_attr that are being set.
  */
 enum cl_attr_valid {
-        CAT_SIZE   = 1 << 0,
-        CAT_KMS    = 1 << 1,
-        CAT_MTIME  = 1 << 3,
-        CAT_ATIME  = 1 << 4,
-        CAT_CTIME  = 1 << 5,
-        CAT_BLOCKS = 1 << 6,
-        CAT_UID    = 1 << 7,
+       CAT_SIZE   = 1 << 0,
+       CAT_KMS    = 1 << 1,
+       CAT_MTIME  = 1 << 3,
+       CAT_ATIME  = 1 << 4,
+       CAT_CTIME  = 1 << 5,
+       CAT_BLOCKS = 1 << 6,
+       CAT_UID    = 1 << 7,
        CAT_GID    = 1 << 8,
        CAT_PROJID = 1 << 9
 };
index 7f4849f..8c10fdb 100644 (file)
@@ -396,6 +396,12 @@ static inline int lu_device_is_md(const struct lu_device *d)
  * Common object attributes.
  */
 struct lu_attr {
+       /**
+        * valid bits
+        *
+        * \see enum la_valid
+        */
+       __u64          la_valid;
         /** size in bytes */
         __u64          la_size;
        /** modification time in seconds since Epoch */
@@ -424,12 +430,6 @@ struct lu_attr {
         __u32          la_rdev;
        /** project id */
        __u32          la_projid;
-        /**
-         * valid bits
-         *
-         * \see enum la_valid
-         */
-        __u64          la_valid;
 };
 
 /** Bit-mask of valid attributes */
index dc1e37c..d3167ed 100644 (file)
@@ -1707,7 +1707,7 @@ struct mdt_body {
        __u32   mbo_unused3; /* was max_cookiesize until 2.8 */
        __u32   mbo_uid_h; /* high 32-bits of uid, for FUID */
        __u32   mbo_gid_h; /* high 32-bits of gid, for FUID */
-       __u32   mbo_projid;
+       __u32   mbo_projid;
        __u64   mbo_padding_6; /* also fix lustre_swab_mdt_body */
        __u64   mbo_padding_7;
        __u64   mbo_padding_8;
@@ -2641,7 +2641,7 @@ struct llog_setattr64_rec_v2 {
        __u32                   lsr_padding1;
        __u64                   lsr_padding2;
        __u64                   lsr_padding3;
-       struct llog_rec_tail    lsr_tail;
+       struct llog_rec_tail    lsr_tail;
 } __attribute__((packed));
 
 struct llog_size_change_rec {
@@ -2886,7 +2886,8 @@ struct obdo {
                                                 * brw: grant space consumed on
                                                 * the client for the write */
        __u32                   o_projid;
-       __u32                   o_padding_4;
+       __u32                   o_padding_4;    /* also fix
+                                                * lustre_swab_obdo() */
        __u64                   o_padding_5;
        __u64                   o_padding_6;
 };
index e06e652..6dfa137 100644 (file)
@@ -746,7 +746,7 @@ static inline char *qtype_name(int qtype)
        case GRPQUOTA:
                return "grp";
        case PRJQUOTA:
-               return "project";
+               return "prj";
        }
        return "unknown";
 }
index ab28b24..0b41879 100644 (file)
 #define MAX_DQ_TIME  604800     /* (7*24*60*60) 1 week */
 #endif
 
-#ifndef LL_MAXQUOTAS
-#define LL_MAXQUOTAS 3
-#endif
-
 struct lquota_id_info;
 struct lquota_trans;
 
index a3a0e22..007fc59 100644 (file)
@@ -835,7 +835,12 @@ struct md_op_data {
 
        /* default stripe offset */
        __u32                   op_default_stripe_offset;
+
        __u32                   op_projid;
+
+       /* Used by readdir */
+       unsigned int            op_max_pages;
+
 };
 
 struct md_callback {
index c217a31..ce4961e 100644 (file)
@@ -1750,8 +1750,9 @@ migrate_free:
                RETURN(rc);
        }
        case LL_IOC_FSGETXATTR:
+               RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg));
        case LL_IOC_FSSETXATTR:
-               RETURN(ll_ioctl_projid(inode, cmd, arg));
+               RETURN(ll_ioctl_fssetxattr(inode, cmd, arg));
        default:
                RETURN(obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL,
                                     (void __user *)arg));
index e829c83..3183ced 100644 (file)
@@ -2364,71 +2364,58 @@ static int ll_ladvise(struct inode *inode, struct file *file, __u64 flags,
        RETURN(rc);
 }
 
-int ll_ioctl_projid(struct inode *inode, unsigned int cmd,
-                   unsigned long arg)
+int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd,
+                       unsigned long arg)
 {
-       int rc = 0;
-       struct fsxattr *fsxattr;
-       int alloc_size = sizeof(*fsxattr);
+       struct fsxattr fsxattr;
 
-       switch (cmd) {
-       case LL_IOC_FSGETXATTR: {
-               OBD_ALLOC_PTR(fsxattr);
-               if (fsxattr == NULL)
-                       RETURN(-ENOMEM);
+       if (copy_from_user(&fsxattr,
+                          (const struct fsxattr __user *)arg,
+                          sizeof(fsxattr)))
+               RETURN(-EFAULT);
 
-               if (copy_from_user(fsxattr,
-                                  (const struct fsxattr __user *)arg,
-                                  alloc_size))
-                       GOTO(out_fsxattr, rc = -EFAULT);
-
-               fsxattr->fsx_projid = ll_i2info(inode)->lli_projid;
-               if (copy_to_user((struct fsxattr __user *)arg,
-                                fsxattr, alloc_size))
-                       GOTO(out_fsxattr, rc = -EFAULT);
-out_fsxattr:
-               OBD_FREE(fsxattr, alloc_size);
-               RETURN(rc);
-       }
+       fsxattr.fsx_projid = ll_i2info(inode)->lli_projid;
+       if (copy_to_user((struct fsxattr __user *)arg,
+                        &fsxattr, sizeof(fsxattr)))
+               RETURN(-EFAULT);
 
-       case LL_IOC_FSSETXATTR: {
-               struct md_op_data *op_data;
-               struct ptlrpc_request *req = NULL;
+       RETURN(0);
+}
 
-               /* only root could change project ID */
-               if (!cfs_capable(CFS_CAP_SYS_ADMIN))
-                       RETURN(-EPERM);
+int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
+                       unsigned long arg)
+{
 
-               op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
-                                            LUSTRE_OPC_ANY, NULL);
-               if (IS_ERR(op_data))
-                       RETURN(PTR_ERR(op_data));
+       struct md_op_data *op_data;
+       struct ptlrpc_request *req = NULL;
+       int rc = 0;
+       struct fsxattr fsxattr;
+
+       /* only root could change project ID */
+       if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+               RETURN(-EPERM);
 
-               OBD_ALLOC_PTR(fsxattr);
-               if (fsxattr == NULL)
-                       GOTO(out_fsxattr1, rc = -ENOMEM);
+       op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
+                                    LUSTRE_OPC_ANY, NULL);
+       if (IS_ERR(op_data))
+               RETURN(PTR_ERR(op_data));
 
-               if (copy_from_user(fsxattr,
-                                  (const struct fsxattr __user *)arg,
-                                  alloc_size))
-                       GOTO(out_fsxattr1, rc = -EFAULT);
+       if (copy_from_user(&fsxattr,
+                          (const struct fsxattr __user *)arg,
+                          sizeof(fsxattr)))
+               GOTO(out_fsxattr1, rc = -EFAULT);
 
-               op_data->op_projid = fsxattr->fsx_projid;
-               op_data->op_attr.ia_valid |= MDS_ATTR_PROJID;
-               rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
-                               0, &req);
-               ptlrpc_req_finished(req);
+       op_data->op_projid = fsxattr.fsx_projid;
+       op_data->op_attr.ia_valid |= MDS_ATTR_PROJID;
+       rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
+                       0, &req);
+       ptlrpc_req_finished(req);
 
 out_fsxattr1:
-               ll_finish_md_op_data(op_data);
-               OBD_FREE(fsxattr, alloc_size);
-               RETURN(rc);
-       }
-       default:
-               LASSERT(0);
-       }
-
+       ll_finish_md_op_data(op_data);
        RETURN(rc);
+
+
 }
 
 static long
@@ -2827,8 +2814,9 @@ out_ladvise:
                RETURN(rc);
        }
        case LL_IOC_FSGETXATTR:
+               RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg));
        case LL_IOC_FSSETXATTR:
-               RETURN(ll_ioctl_projid(inode, cmd, arg));
+               RETURN(ll_ioctl_fssetxattr(inode, cmd, arg));
        default: {
                int err;
 
index 07bd134..f5ee50a 100644 (file)
@@ -814,8 +814,10 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
 int ll_inode_permission(struct inode *inode, int mask);
 # endif
 #endif
-int ll_ioctl_projid(struct inode *inode, unsigned int cmd,
-                   unsigned long arg);
+int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd,
+                       unsigned long arg);
+int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
+                       unsigned long arg);
 
 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
                             __u64  flags, struct lov_user_md *lum,
index d75f94c..f9996e3 100644 (file)
@@ -1670,10 +1670,9 @@ int ll_setattr(struct dentry *de, struct iattr *attr)
            !(attr->ia_valid & ATTR_KILL_SGID))
                attr->ia_valid |= ATTR_KILL_SGID;
 
-       /* avoid polluted from ATTR_TIMES_SET, projid is not
-        * expected to be setted here */
-       if (attr->ia_valid & MDS_ATTR_PROJID)
-               attr->ia_valid &= ~MDS_ATTR_PROJID;
+       /* avoid polluted from ATTR_TIMES_SET,
+        * projid is not expected to be set here */
+       attr->ia_valid &= ~MDS_ATTR_PROJID;
 
        return ll_setattr_raw(de, attr, false);
 }
index d74cbbd..d1ab06c 100644 (file)
@@ -1131,12 +1131,13 @@ static int lod_declare_attr_set(const struct lu_env *env,
                RETURN(rc);
 
        /* osp_declare_attr_set() ignores all attributes other than
-        * UID, GID, PID, and size, and osp_attr_set() ignores all but
-        * UID, GID and PID. Declaration of size attr setting happens
-        * through lod_declare_init_size(), and not through this function.
-        * Therefore we need not load striping unless ownership is
-        * changing.  This should save memory and (we hope) speed up
-        * rename(). */
+        * UID, GID, PROJID, and size, and osp_attr_set() ignores all
+        * but UID, GID and PROJID. Declaration of size attr setting
+        * happens through lod_declare_init_size(), and not through
+        * this function. Therefore we need not load striping unless
+        * ownership is changing.  This should save memory and (we hope)
+        * speed up rename().
+        */
        if (!S_ISDIR(dt->do_lu.lo_header->loh_attr)) {
                if (!(attr->la_valid & (LA_UID | LA_GID | LA_PROJID)))
                        RETURN(rc);
index 72a2497..32158e7 100644 (file)
@@ -596,7 +596,7 @@ static int mdt_attr_set(struct mdt_thread_info *info, struct mdt_object *mo,
 {
        struct mdt_lock_handle  *lh;
        int do_vbr = ma->ma_attr.la_valid &
-                       (LA_MODE|LA_UID|LA_GID|LA_PROJID|LA_FLAGS);
+                       (LA_MODE | LA_UID | LA_GID | LA_PROJID | LA_FLAGS);
        __u64 lockpart = MDS_INODELOCK_UPDATE;
        struct ldlm_enqueue_info *einfo = &info->mti_einfo;
        struct lu_fid *s0_fid = &info->mti_tmp_fid1;
index cd248cd..480a9f5 100644 (file)
@@ -249,7 +249,7 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec)
 
                if (rec->lrh_len > sizeof(struct llog_setattr64_rec)) {
                        struct llog_setattr64_rec_v2 *lsr2 =
-                       (struct llog_setattr64_rec_v2 *)rec;
+                               (struct llog_setattr64_rec_v2 *)rec;
 
                        __swab32s(&lsr2->lsr_projid);
                        tail = &lsr2->lsr_tail;
index bbaf086..2ddd44d 100644 (file)
@@ -881,7 +881,7 @@ ofd_write_attr_set(const struct lu_env *env, struct ofd_device *ofd,
        if (rc)
                GOTO(out_tx, rc);
 
-       /* set uid/gid/pid */
+       /* set uid/gid/projid */
        if (la->la_valid) {
                rc = dt_attr_set(env, dt_obj, la, th);
                if (rc)
index 99baeb8..6c3b354 100644 (file)
@@ -1462,17 +1462,17 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
                 RETURN(-EPROTO);
         }
 
-        /* set/clear over quota flag for a uid/gid/projid */
-        if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE &&
-            body->oa.o_valid & (OBD_MD_FLALLQUOTA)) {
-               unsigned qid[LL_MAXQUOTAS] =
-                                       { body->oa.o_uid, body->oa.o_gid,
+       /* set/clear over quota flag for a uid/gid/projid */
+       if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE &&
+           body->oa.o_valid & (OBD_MD_FLALLQUOTA)) {
+               unsigned qid[LL_MAXQUOTAS] = {
+                                        body->oa.o_uid, body->oa.o_gid,
                                         body->oa.o_projid };
-
                CDEBUG(D_QUOTA, "setdq for [%u %u %u] with valid %#llx, flags %x\n",
-                       body->oa.o_uid, body->oa.o_gid, body->oa.o_projid,
+                      body->oa.o_uid, body->oa.o_gid, body->oa.o_projid,
                       body->oa.o_valid, body->oa.o_flags);
-                osc_quota_setdq(cli, qid, body->oa.o_valid, body->oa.o_flags);
+                      osc_quota_setdq(cli, qid, body->oa.o_valid,
+                                      body->oa.o_flags);
         }
 
         osc_update_grant(cli, body);
index 2876e6e..262e6bf 100644 (file)
@@ -2450,7 +2450,7 @@ static int osd_declare_attr_qid(const struct lu_env *env,
        /* block accounting */
        qi->lqi_is_blk = true;
 
-       /* more blocks for the new uid ... */
+       /* more blocks for the new id ... */
        qi->lqi_id.qid_uid = new_id;
        qi->lqi_space      = bspace;
        /*
@@ -2520,27 +2520,27 @@ static int osd_declare_attr_set(const struct lu_env *env,
                uid = i_uid_read(obj->oo_inode);
                enforce = (attr->la_valid & LA_UID) && (attr->la_uid != uid);
                rc = osd_declare_attr_qid(env, obj, oh, bspace, uid,
-                               attr->la_uid, enforce, USRQUOTA);
+                                         attr->la_uid, enforce, USRQUOTA);
                if (rc)
                        RETURN(rc);
 
                gid = i_gid_read(obj->oo_inode);
                enforce = (attr->la_valid & LA_GID) && (attr->la_gid != gid);
                rc = osd_declare_attr_qid(env, obj, oh, bspace,
-                               i_gid_read(obj->oo_inode), attr->la_gid,
-                               enforce, GRPQUOTA);
+                                         i_gid_read(obj->oo_inode),
+                                         attr->la_gid, enforce, GRPQUOTA);
                if (rc)
                        RETURN(rc);
 
        }
-#ifdef HAVE_PROJECT_QUOTA
+#ifdef HAVE_PROJECT_QUOTA
        if (attr->la_valid & LA_PROJID) {
                __u32 projid = i_projid_read(obj->oo_inode);
                enforce = (attr->la_valid & LA_PROJID) &&
                                        (attr->la_projid != projid);
                rc = osd_declare_attr_qid(env, obj, oh, bspace,
-                               (qid_t)projid, (qid_t)attr->la_projid,
-                               enforce, PRJQUOTA);
+                                         (qid_t)projid, (qid_t)attr->la_projid,
+                                         enforce, PRJQUOTA);
                if (rc)
                        RETURN(rc);
        }
@@ -2630,10 +2630,10 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr)
                }
        }
 
-#ifdef HAVE_PROJECT_QUOTA
+#ifdef HAVE_PROJECT_QUOTA
        /* Handle project id transfer here properly */
-       if (attr->la_valid & LA_PROJID && attr->la_projid !=
-                                               i_projid_read(inode)) {
+       if (attr->la_valid & LA_PROJID &&
+           attr->la_projid != i_projid_read(inode)) {
                rc = __ldiskfs_ioctl_setproject(inode, attr->la_projid);
                if (rc) {
                        CERROR("%s: quota transfer failed: rc = %d. Is quota "
@@ -3130,7 +3130,7 @@ static int osd_declare_object_create(const struct lu_env *env,
 
        rc = osd_declare_inode_qid(env, attr->la_uid, attr->la_gid,
                                   attr->la_projid, 1, oh, osd_dt_obj(dt),
-                                  false, NULL, false);
+                                  NULL, OSD_QID_INODE);
        if (rc != 0)
                RETURN(rc);
 
@@ -3208,14 +3208,14 @@ static int osd_declare_object_destroy(const struct lu_env *env,
                             osd_dto_credits_noquota[DTO_INDEX_DELETE] + 3);
        /* one less inode */
        rc = osd_declare_inode_qid(env, i_uid_read(inode), i_gid_read(inode),
-                                  i_projid_read(inode), -1, oh, obj, false,
-                                  NULL, false);
+                                  i_projid_read(inode), -1, oh, obj, NULL,
+                                  OSD_QID_INODE);
        if (rc)
                RETURN(rc);
        /* data to be truncated */
        rc = osd_declare_inode_qid(env, i_uid_read(inode), i_gid_read(inode),
-                                  i_projid_read(inode), 0, oh, obj, true,
-                                  NULL, false);
+                                  i_projid_read(inode), 0, oh, obj, NULL,
+                                  OSD_QID_BLK);
        if (rc)
                RETURN(rc);
 
@@ -3470,7 +3470,7 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env,
        ldiskfs_set_inode_state(local, LDISKFS_STATE_LUSTRE_NOSCRUB);
        unlock_new_inode(local);
 
-       /* Agent inode should not have project ID*/
+       /* Agent inode should not have project ID */
 #ifdef HAVE_PROJECT_QUOTA
        if (LDISKFS_I(pobj->oo_inode)->i_flags & LUSTRE_PROJINHERIT_FL) {
                rc = __ldiskfs_ioctl_setproject(local, 0);
@@ -3481,7 +3481,6 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env,
                        RETURN(ERR_PTR(rc));
                }
        }
-
 #endif
        /* Set special LMA flag for local agent inode */
        rc = osd_ea_fid_set(info, local, fid, 0, LMAI_AGENT);
@@ -4566,7 +4565,7 @@ static int osd_index_declare_ea_delete(const struct lu_env *env,
 
        rc = osd_declare_inode_qid(env, i_uid_read(inode), i_gid_read(inode),
                                   i_projid_read(inode), 0, oh, osd_dt_obj(dt),
-                                  true, NULL, false);
+                                  NULL, OSD_QID_BLK);
        RETURN(rc);
 }
 
@@ -5451,8 +5450,8 @@ static int osd_index_declare_ea_insert(const struct lu_env *env,
                rc = osd_declare_inode_qid(env, i_uid_read(inode),
                                           i_gid_read(inode),
                                           i_projid_read(inode), 0,
-                                          oh, osd_dt_obj(dt), true,
-                                          NULL, false);
+                                          oh, osd_dt_obj(dt), NULL,
+                                          OSD_QID_BLK);
        }
 
        RETURN(rc);
index c495687..a96521f 100644 (file)
@@ -625,6 +625,13 @@ struct osd_thread_info {
        unsigned int            oti_declare_ops_used[OSD_OT_MAX];
 };
 
+/* flags for inode/block quota accounting */
+enum osd_qid_declare_flags {
+       OSD_QID_INODE   = 1 << 0,
+       OSD_QID_BLK     = 1 << 1,
+       OSD_QID_FORCE   = 1 << 2,
+};
+
 extern int ldiskfs_pdo;
 
 static inline int __osd_xattr_get(struct inode *inode, struct dentry *dentry,
@@ -744,8 +751,8 @@ int osd_declare_qid(const struct lu_env *env, struct osd_thandle *oh,
                    bool enforce, int *flags);
 int osd_declare_inode_qid(const struct lu_env *env, qid_t uid, qid_t gid,
                          __u32 projid, long long space, struct osd_thandle *oh,
-                         struct osd_object *obj, bool is_blk, int *flags,
-                         bool force);
+                         struct osd_object *obj, int *flags,
+                         enum osd_qid_declare_flags);
 const struct dt_rec *osd_quota_pack(struct osd_object *obj,
                                    const struct dt_rec *rec,
                                    union lquota_rec *quota_rec);
index 7a802d3..c5c70e6 100644 (file)
@@ -1107,19 +1107,19 @@ static int osd_declare_write_commit(const struct lu_env *env,
                                     struct niobuf_local *lnb, int npages,
                                     struct thandle *handle)
 {
-        const struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt));
-        struct inode            *inode = osd_dt_obj(dt)->oo_inode;
-        struct osd_thandle      *oh;
-        int                      extents = 1;
-        int                      depth;
-        int                      i;
-        int                      newblocks;
-       int                      rc = 0;
-       int                      flags = 0;
-       int                      credits = 0;
-       bool                     ignore_quota = false;
-       long long                quota_space = 0;
-       struct osd_fextent       extent = { 0 };
+       const struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt));
+       struct inode            *inode = osd_dt_obj(dt)->oo_inode;
+       struct osd_thandle      *oh;
+       int                     extents = 1;
+       int                     depth;
+       int                     i;
+       int                     newblocks;
+       int                     rc = 0;
+       int                     flags = 0;
+       int                     credits = 0;
+       long long               quota_space = 0;
+       struct osd_fextent      extent = { 0 };
+       enum osd_qid_declare_flags declare_flags = OSD_QID_BLK;
        ENTRY;
 
         LASSERT(handle != NULL);
@@ -1149,7 +1149,7 @@ static int osd_declare_write_commit(const struct lu_env *env,
                if ((lnb[i].lnb_flags & OBD_BRW_NOQUOTA) ||
                    (lnb[i].lnb_flags & (OBD_BRW_FROM_GRANT | OBD_BRW_SYNC)) ==
                    OBD_BRW_FROM_GRANT)
-                       ignore_quota = true;
+                       declare_flags |= OSD_QID_FORCE;
        }
 
         /*
@@ -1201,7 +1201,7 @@ static int osd_declare_write_commit(const struct lu_env *env,
 
        rc = osd_declare_inode_qid(env, i_uid_read(inode), i_gid_read(inode),
                                   i_projid_read(inode), quota_space, oh,
-                                  osd_dt_obj(dt), true, &flags, ignore_quota);
+                                  osd_dt_obj(dt), &flags, declare_flags);
 
        /* we need only to store the overquota flags in the first lnb for
         * now, once we support multiple objects BRW, this code needs be
@@ -1639,7 +1639,7 @@ out:
                rc = osd_declare_inode_qid(env, i_uid_read(inode),
                                           i_gid_read(inode),
                                           i_projid_read(inode), 0,
-                                          oh, obj, true, NULL, false);
+                                          oh, obj, NULL, OSD_QID_BLK);
        RETURN(rc);
 }
 
@@ -1814,7 +1814,7 @@ static int osd_declare_punch(const struct lu_env *env, struct dt_object *dt,
 
        rc = osd_declare_inode_qid(env, i_uid_read(inode), i_gid_read(inode),
                                   i_projid_read(inode), 0, oh, osd_dt_obj(dt),
-                                  true, NULL, false);
+                                  NULL, OSD_QID_BLK);
        RETURN(rc);
 }
 
index 90e8ad6..2345501 100644 (file)
@@ -87,16 +87,15 @@ int osd_acct_obj_lookup(struct osd_thread_info *info, struct osd_device *osd,
                        le32_to_cpu(LDISKFS_SB(sb)->s_es->s_grp_quota_inum);
                break;
        case PRJQUOTA:
-#ifdef HAVE_PROJECT_QUOTA
-               if (!LDISKFS_HAS_RO_COMPAT_FEATURE(sb,
-                               LDISKFS_FEATURE_RO_COMPAT_PROJECT))
-                       RETURN(-ENOTSUPP);
-               id->oii_ino =
-                       le32_to_cpu(LDISKFS_SB(sb)->s_es->s_prj_quota_inum);
+ #ifdef HAVE_PROJECT_QUOTA
+               if (LDISKFS_HAS_RO_COMPAT_FEATURE(sb,
+                                       LDISKFS_FEATURE_RO_COMPAT_PROJECT))
+                       id->oii_ino =
+                               le32_to_cpu(LDISKFS_SB(sb)->s_es->s_prj_quota_inum);
+               else
+ #endif
+                       RETURN(-ENOENT);
                break;
-#else
-               RETURN(-ENOTSUPP);
-#endif
        }
        if (!ldiskfs_valid_inum(sb, id->oii_ino))
                RETURN(-ENOENT);
@@ -611,30 +610,30 @@ int osd_declare_qid(const struct lu_env *env, struct osd_thandle *oh,
  * \param  space  - how many blocks/inodes will be consumed/released
  * \param  oh     - osd transaction handle
  * \param  obj    - osd object, could be NULL when it's under create
- * \param  is_blk - block quota or inode quota?
  * \param  flags  - if the operation is write, return no user quota, no
  *                  group quota, or sync commit flags to the caller
- * \param force   - set to 1 when changes are performed by root user and thus
- *                  can't failed with EDQUOT
+ * \param osd_qid_flags - indicate this is a inode/block accounting
+ *                     and whether changes are performed by root user
  *
  * \retval 0      - success
  * \retval -ve    - failure
  */
 int osd_declare_inode_qid(const struct lu_env *env, qid_t uid, qid_t gid,
                          __u32 projid, long long space, struct osd_thandle *oh,
-                         struct osd_object *obj, bool is_blk, int *flags,
-                         bool force)
+                         struct osd_object *obj, int *flags,
+                         enum osd_qid_declare_flags osd_qid_declare_flags)
 {
        struct osd_thread_info  *info = osd_oti_get(env);
        struct lquota_id_info   *qi = &info->oti_qi;
-       int                      rcu, rcg, rcp; /* user & group & project rc */
+       int rcu, rcg, rcp; /* user & group & project rc */
+       int force = osd_qid_declare_flags & OSD_QID_FORCE;
        ENTRY;
 
        /* let's start with user quota */
        qi->lqi_id.qid_uid = uid;
        qi->lqi_type       = USRQUOTA;
        qi->lqi_space      = space;
-       qi->lqi_is_blk     = is_blk;
+       qi->lqi_is_blk     = !!(osd_qid_declare_flags & OSD_QID_BLK);
        rcu = osd_declare_qid(env, oh, qi, obj, true, flags);
 
        if (force && (rcu == -EDQUOT || rcu == -EINPROGRESS))
index 7f437ca..d8190a8 100644 (file)
@@ -499,11 +499,11 @@ static inline int osd_oid(struct osd_device *dev, __u32 local_oid,
                return 0;
        case ACCT_PROJECT_OID:
                /* TODO: real oid */
-               CERROR("unsupported quota oid: %#x\n", local_oid);
+               CERROR("%s: unsupported quota oid: %#x\n",
+                       osd_name(dev), local_oid);
                return -ENOTSUPP;
        }
 
-       LASSERTF(0, "invalid oid: %u for quota type", local_oid);
        return -ENOTSUPP;
 }
 
index 5cf1793..5367ae4 100644 (file)
@@ -1709,35 +1709,35 @@ static void lustre_swab_ost_layout(struct ost_layout *ol)
 
 void lustre_swab_obdo (struct obdo  *o)
 {
-        __swab64s (&o->o_valid);
+       __swab64s(&o->o_valid);
        lustre_swab_ost_id(&o->o_oi);
-        __swab64s (&o->o_parent_seq);
-        __swab64s (&o->o_size);
-        __swab64s (&o->o_mtime);
-        __swab64s (&o->o_atime);
-        __swab64s (&o->o_ctime);
-        __swab64s (&o->o_blocks);
-        __swab64s (&o->o_grant);
-        __swab32s (&o->o_blksize);
-        __swab32s (&o->o_mode);
-        __swab32s (&o->o_uid);
-        __swab32s (&o->o_gid);
-        __swab32s (&o->o_flags);
-        __swab32s (&o->o_nlink);
-        __swab32s (&o->o_parent_oid);
-        __swab32s (&o->o_misc);
-        __swab64s (&o->o_ioepoch);
-        __swab32s (&o->o_stripe_idx);
-        __swab32s (&o->o_parent_ver);
+       __swab64s(&o->o_parent_seq);
+       __swab64s(&o->o_size);
+       __swab64s(&o->o_mtime);
+       __swab64s(&o->o_atime);
+       __swab64s(&o->o_ctime);
+       __swab64s(&o->o_blocks);
+       __swab64s(&o->o_grant);
+       __swab32s(&o->o_blksize);
+       __swab32s(&o->o_mode);
+       __swab32s(&o->o_uid);
+       __swab32s(&o->o_gid);
+       __swab32s(&o->o_flags);
+       __swab32s(&o->o_nlink);
+       __swab32s(&o->o_parent_oid);
+       __swab32s(&o->o_misc);
+       __swab64s(&o->o_ioepoch);
+       __swab32s(&o->o_stripe_idx);
+       __swab32s(&o->o_parent_ver);
        lustre_swab_ost_layout(&o->o_layout);
        CLASSERT(offsetof(typeof(*o), o_padding_3) != 0);
-        __swab32s (&o->o_uid_h);
-        __swab32s (&o->o_gid_h);
-        __swab64s (&o->o_data_version);
+       __swab32s(&o->o_uid_h);
+       __swab32s(&o->o_gid_h);
+       __swab64s(&o->o_data_version);
        __swab32s(&o->o_projid);
-        CLASSERT(offsetof(typeof(*o), o_padding_4) != 0);
-        CLASSERT(offsetof(typeof(*o), o_padding_5) != 0);
-        CLASSERT(offsetof(typeof(*o), o_padding_6) != 0);
+       CLASSERT(offsetof(typeof(*o), o_padding_4) != 0);
+       CLASSERT(offsetof(typeof(*o), o_padding_5) != 0);
+       CLASSERT(offsetof(typeof(*o), o_padding_6) != 0);
 
 }
 EXPORT_SYMBOL(lustre_swab_obdo);
@@ -1889,6 +1889,10 @@ void lustre_swab_mdt_body (struct mdt_body *b)
        __swab32s(&b->mbo_gid_h);
        __swab32s(&b->mbo_projid);
        CLASSERT(offsetof(typeof(*b), mbo_padding_6) != 0);
+       CLASSERT(offsetof(typeof(*b), mbo_padding_7) != 0);
+       CLASSERT(offsetof(typeof(*b), mbo_padding_8) != 0);
+       CLASSERT(offsetof(typeof(*b), mbo_padding_9) != 0);
+       CLASSERT(offsetof(typeof(*b), mbo_padding_10) != 0);
 }
 
 void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b)
index 5361b7d..f7d30b3 100644 (file)
 #ifndef _LQUOTA_INTERNAL_H
 #define _LQUOTA_INTERNAL_H
 
-/*
-static inline char *qtype_name(int qtype)
-{
-       switch (qtype) {
-       case USRQUOTA:
-               return "usr";
-       case GRPQUOTA:
-               return "grp";
-       case PRJQUOTA:
-               return "prj";
-               break;
-       }
-       return "unknown";
-}
-*/
-
 #define RES_NAME(res) ((res) == LQUOTA_RES_MD ? "md" : "dt")
 
 #define QIF_IFLAGS (QIF_INODES | QIF_ITIME | QIF_ILIMITS)
@@ -77,7 +61,7 @@ static inline __u32 qtype2slv_oid(int qtype)
                return LQUOTA_PRJ_OID;
        }
 
-       LASSERTF(0, "invalid quota type: %d", qtype);
+       /* should not come here, just make compile happy */
        return LQUOTA_USR_OID;
 }
 
@@ -321,7 +305,7 @@ static inline int lquota_over_fl(int qtype)
                return QUOTA_FL_OVER_PRJQUOTA;
        }
 
-       LASSERTF(0, "invalid quota type: %d", qtype);
+       /* should not come here, just make compile happy */
        return QUOTA_FL_OVER_USRQUOTA;
 }
 
index 382f94d..2b94391 100644 (file)
@@ -186,8 +186,7 @@ int lquotactl_slv(const struct lu_env *env, struct dt_device *dev,
                RETURN(-EOPNOTSUPP);
        }
 
-       if (oqctl->qc_type < 0 || oqctl->qc_type >= MAXQUOTAS)
-               /* no support for directory quota yet */
+       if (oqctl->qc_type < 0 || oqctl->qc_type >= LL_MAXQUOTAS)
                RETURN(-EOPNOTSUPP);
 
        /* qc_id is a 32-bit field while a key has 64 bits */
index cc2bd32..5478683 100644 (file)
@@ -355,6 +355,8 @@ static void qsd_qtype_fini(const struct lu_env *env, struct qsd_instance *qsd,
 
 static const char *qtype2acct_name(int qtype)
 {
+       static char unknown[24];
+
        switch (qtype) {
        case USRQUOTA:
                return "acct_user";
@@ -364,12 +366,14 @@ static const char *qtype2acct_name(int qtype)
                return "acct_project";
        }
 
-       LASSERTF(0, "invalid quota type: %d", qtype);
-       return NULL;
+       snprintf(unknown, sizeof(unknown), "acct_unknown_%u", qtype);
+       return unknown;
 }
 
 static const char *qtype2glb_name(int qtype)
 {
+       static char unknown[24];
+
        switch (qtype) {
        case USRQUOTA:
                return "limit_user";
@@ -379,8 +383,8 @@ static const char *qtype2glb_name(int qtype)
                return "limit_project";
        }
 
-       LASSERTF(0, "invalid quota type: %d", qtype);
-       return NULL;
+       snprintf(unknown, sizeof(unknown), "acct_unknown_%u", qtype);
+       return unknown;
 }
 
 /*
index 7371289..e8afb01 100644 (file)
@@ -280,12 +280,12 @@ command_t cmdlist[] = {
         "usage: setquota <-u|-g|-p> <uname>|<uid>|<gname>|<gid>|<projid>\n"
          "                -b <block-softlimit> -B <block-hardlimit>\n"
          "                -i <inode-softlimit> -I <inode-hardlimit> <filesystem>\n"
-        "       setquota <-u|--user|-g|--group|-p|--project> <uname>|<uid>|<gname>|<gid>|<projid>\n"
+        "       setquota <-u|--user|-g|--group|-p|--projid> <uname>|<uid>|<gname>|<gid>|<projid>\n"
          "                [--block-softlimit <block-softlimit>]\n"
          "                [--block-hardlimit <block-hardlimit>]\n"
          "                [--inode-softlimit <inode-softlimit>]\n"
          "                [--inode-hardlimit <inode-hardlimit>] <filesystem>\n"
-        "       setquota [-t] <-u|--user|-g|--group|-p|--project>\n"
+        "       setquota [-t] <-u|--user|-g|--group|-p|--projid>\n"
          "                [--block-grace <block-grace>]\n"
          "                [--inode-grace <inode-grace>] <filesystem>\n"
          "       -b can be used instead of --block-softlimit/--block-grace\n"
@@ -3502,7 +3502,7 @@ int lfs_setquota_times(int argc, char **argv)
                 {"block-grace",     required_argument, 0, 'b'},
                 {"group",           no_argument,       0, 'g'},
                 {"inode-grace",     required_argument, 0, 'i'},
-               {"project",         no_argument,       0, 'p'},
+               {"projid",          no_argument,       0, 'p'},
                 {"times",           no_argument,       0, 't'},
                 {"user",            no_argument,       0, 'u'},
                 {0, 0, 0, 0}
@@ -3596,7 +3596,7 @@ int lfs_setquota(int argc, char **argv)
                 {"inode-softlimit", required_argument, 0, 'i'},
                 {"inode-hardlimit", required_argument, 0, 'I'},
                 {"user",            required_argument, 0, 'u'},
-               {"project",         required_argument, 0, 'p'},
+               {"projid",         required_argument, 0, 'p'},
                 {0, 0, 0, 0}
         };
         unsigned limit_mask = 0;
@@ -3609,13 +3609,13 @@ int lfs_setquota(int argc, char **argv)
        memset(&qctl, 0, sizeof(qctl));
        qctl.qc_cmd  = LUSTRE_Q_SETQUOTA;
        qctl.qc_type = ALLQUOTA; /* ALLQUOTA makes no sense for setquota,
-                                 * so it can be used as a marker that qc_type
-                                 * isn't reinitialized from command line */
+                                 * so it can be used as a marker that qc_type
+                                 * isn't reinitialized from command line */
 
        while ((c = getopt_long(argc, argv, "b:B:g:i:I:p:u:",
                long_opts, NULL)) != -1) {
-                switch (c) {
-                case 'u':
+               switch (c) {
+               case 'u':
                        qtype = USRQUOTA;
                        rc = name2uid(&qctl.qc_id, optarg);
                        goto quota_type;
@@ -4106,8 +4106,8 @@ all_output:
                if (rc) {
                        qctl.qc_id = strtoul(name, &endptr, 10);
                        if (*endptr != '\0') {
-                               fprintf(stderr, "error: can't find id for name "
-                                        "%s\n", name);
+                               fprintf(stderr, "error: can't find id for name: %s\n",
+                                               name);
                                return CMD_HELP;
                        }
                }
@@ -4116,9 +4116,8 @@ all_output:
                return CMD_HELP;
        }
 
-        mnt = argv[optind];
-
-        rc1 = llapi_quotactl(mnt, &qctl);
+       mnt = argv[optind];
+       rc1 = llapi_quotactl(mnt, &qctl);
        if (rc1 < 0) {
                switch (rc1) {
                case -ESRCH: