[Cluster-devel] [PATCH 01/12] quota: Remove const from function declarations

2014-11-04 Thread Jan Kara
We don't use const through VFS too much so just remove it from quota
function declarations.

Signed-off-by: Jan Kara j...@suse.cz
---
 fs/quota/dquot.c | 4 ++--
 include/linux/quotaops.h | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8b663b2d9562..8a6b95e9bf3d 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1643,7 +1643,7 @@ EXPORT_SYMBOL(__dquot_alloc_space);
 /*
  * This operation can block, but only after everything is updated
  */
-int dquot_alloc_inode(const struct inode *inode)
+int dquot_alloc_inode(struct inode *inode)
 {
int cnt, ret = 0, index;
struct dquot_warn warn[MAXQUOTAS];
@@ -1784,7 +1784,7 @@ EXPORT_SYMBOL(__dquot_free_space);
 /*
  * This operation can block, but only after everything is updated
  */
-void dquot_free_inode(const struct inode *inode)
+void dquot_free_inode(struct inode *inode)
 {
unsigned int cnt;
struct dquot_warn warn[MAXQUOTAS];
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 1d3eee594cd6..f23538a6e411 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -64,10 +64,10 @@ void dquot_destroy(struct dquot *dquot);
 int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags);
 void __dquot_free_space(struct inode *inode, qsize_t number, int flags);
 
-int dquot_alloc_inode(const struct inode *inode);
+int dquot_alloc_inode(struct inode *inode);
 
 int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
-void dquot_free_inode(const struct inode *inode);
+void dquot_free_inode(struct inode *inode);
 void dquot_reclaim_space_nodirty(struct inode *inode, qsize_t number);
 
 int dquot_disable(struct super_block *sb, int type, unsigned int flags);
@@ -213,12 +213,12 @@ static inline void dquot_drop(struct inode *inode)
 {
 }
 
-static inline int dquot_alloc_inode(const struct inode *inode)
+static inline int dquot_alloc_inode(struct inode *inode)
 {
return 0;
 }
 
-static inline void dquot_free_inode(const struct inode *inode)
+static inline void dquot_free_inode(struct inode *inode)
 {
 }
 
-- 
1.8.1.4



[Cluster-devel] [PATCH 02/12] quota: Allow each filesystem to specify which quota types it supports

2014-11-04 Thread Jan Kara
Currently all filesystems supporting VFS quota support user and group
quotas. With introduction of project quotas this is going to change so
make sure filesystem isn't called for quota type it doesn't support by
introduction of a bitmask determining which quota types each filesystem
supports.

Signed-off-by: Jan Kara j...@suse.cz
---
 fs/quota/quota.c  | 13 +++--
 fs/super.c|  6 ++
 include/linux/fs.h|  1 +
 include/linux/quota.h |  5 +
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index 75621649dbd7..2aa4151f99d2 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -47,8 +47,11 @@ static int check_quotactl_permission(struct super_block *sb, 
int type, int cmd,
 
 static void quota_sync_one(struct super_block *sb, void *arg)
 {
-   if (sb-s_qcop  sb-s_qcop-quota_sync)
-   sb-s_qcop-quota_sync(sb, *(int *)arg);
+   int type = *(int *)arg;
+
+   if (sb-s_qcop  sb-s_qcop-quota_sync 
+   (sb-s_quota_types  (1  type)))
+   sb-s_qcop-quota_sync(sb, type);
 }
 
 static int quota_sync_all(int type)
@@ -297,8 +300,14 @@ static int do_quotactl(struct super_block *sb, int type, 
int cmd, qid_t id,
 
if (type = (XQM_COMMAND(cmd) ? XQM_MAXQUOTAS : MAXQUOTAS))
return -EINVAL;
+   /*
+* Quota not supported on this fs? Check this before s_quota_types
+* since they needn't be set if quota is not supported at all.
+*/
if (!sb-s_qcop)
return -ENOSYS;
+   if (!(sb-s_quota_types  (1  type)))
+   return -EINVAL;
 
ret = check_quotactl_permission(sb, type, cmd, id);
if (ret  0)
diff --git a/fs/super.c b/fs/super.c
index eae088f6aaae..4512281df8ff 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -218,6 +218,12 @@ static struct super_block *alloc_super(struct 
file_system_type *type, int flags)
atomic_set(s-s_active, 1);
mutex_init(s-s_vfs_rename_mutex);
lockdep_set_class(s-s_vfs_rename_mutex, type-s_vfs_rename_key);
+   /*
+* For now MAXQUOTAS check in do_quotactl() will limit quota type
+* appropriately. When each fs sets allowed_types, we can remove the
+* line below
+*/
+   s-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
mutex_init(s-s_dquot.dqio_mutex);
mutex_init(s-s_dquot.dqonoff_mutex);
s-s_maxbytes = MAX_NON_LFS;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a957d4366c24..770b466f2b44 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1208,6 +1208,7 @@ struct super_block {
struct backing_dev_info *s_bdi;
struct mtd_info *s_mtd;
struct hlist_node   s_instances;
+   unsigned ints_quota_types;  /* Bitmask of supported quota 
types */
struct quota_info   s_dquot;/* Diskquota specific options */
 
struct sb_writers   s_writers;
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 80d345a3524c..50978b781a19 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -56,6 +56,11 @@ enum quota_type {
PRJQUOTA = 2,   /* element used for project quotas */
 };
 
+/* Masks for quota types when used as a bitmask */
+#define QTYPE_MASK_USR (1  USRQUOTA)
+#define QTYPE_MASK_GRP (1  GRPQUOTA)
+#define QTYPE_MASK_PRJ (1  PRJQUOTA)
+
 typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
 typedef long long qsize_t; /* Type in which we store sizes */
 
-- 
1.8.1.4



[Cluster-devel] [PATCH 11/12] jfs: Convert to private i_dquot field

2014-11-04 Thread Jan Kara
CC: Dave Kleikamp dave.kleik...@oracle.com
CC: jfs-discuss...@lists.sourceforge.net
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/jfs/jfs_incore.h | 3 +++
 fs/jfs/super.c  | 9 +
 2 files changed, 12 insertions(+)

diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
index cf47f09e8ac8..fa7e795bd8ae 100644
--- a/fs/jfs/jfs_incore.h
+++ b/fs/jfs/jfs_incore.h
@@ -94,6 +94,9 @@ struct jfs_inode_info {
unchar _inline_ea[128]; /* 128: inline extended attr */
} link;
} u;
+#ifdef CONFIG_QUOTA
+   struct dquot *i_dquot[MAXQUOTAS];
+#endif
u32 dev;/* will die when we get wide dev_t */
struct inodevfs_inode;
 };
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 93e897e588a8..16c3a9556634 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -117,6 +117,9 @@ static struct inode *jfs_alloc_inode(struct super_block *sb)
jfs_inode = kmem_cache_alloc(jfs_inode_cachep, GFP_NOFS);
if (!jfs_inode)
return NULL;
+#ifdef CONFIG_QUOTA
+   memset(jfs_inode-i_dquot, 0, sizeof(jfs_inode-i_dquot));
+#endif
return jfs_inode-vfs_inode;
 }
 
@@ -537,6 +540,7 @@ static int jfs_fill_super(struct super_block *sb, void 
*data, int silent)
 #ifdef CONFIG_QUOTA
sb-dq_op = dquot_operations;
sb-s_qcop = dquot_quotactl_ops;
+   sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
 #endif
 
/*
@@ -836,6 +840,10 @@ out:
return len - towrite;
 }
 
+static struct dquot **jfs_get_dquots(struct inode *inode)
+{
+   return JFS_IP(inode)-i_dquot;
+}
 #endif
 
 static const struct super_operations jfs_super_operations = {
@@ -854,6 +862,7 @@ static const struct super_operations jfs_super_operations = 
{
 #ifdef CONFIG_QUOTA
.quota_read = jfs_quota_read,
.quota_write= jfs_quota_write,
+   .get_dquots = jfs_get_dquots,
 #endif
 };
 
-- 
1.8.1.4



[Cluster-devel] [PATCH 06/12] ext2: Convert to private i_dquot field

2014-11-04 Thread Jan Kara
CC: linux-e...@vger.kernel.org
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/ext2/ext2.h  |  3 +++
 fs/ext2/super.c | 10 ++
 2 files changed, 13 insertions(+)

diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index d9a17d0b124d..e4279ead4a05 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -689,6 +689,9 @@ struct ext2_inode_info {
struct mutex truncate_mutex;
struct inodevfs_inode;
struct list_head i_orphan;  /* unlinked but open inodes */
+#ifdef CONFIG_QUOTA
+   struct dquot *i_dquot[MAXQUOTAS];
+#endif
 };
 
 /*
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 170dc41e8bf4..ae55fddc26a9 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -166,6 +166,10 @@ static struct inode *ext2_alloc_inode(struct super_block 
*sb)
return NULL;
ei-i_block_alloc_info = NULL;
ei-vfs_inode.i_version = 1;
+#ifdef CONFIG_QUOTA
+   memset(ei-i_dquot, 0, sizeof(ei-i_dquot));
+#endif
+
return ei-vfs_inode;
 }
 
@@ -303,6 +307,10 @@ static int ext2_show_options(struct seq_file *seq, struct 
dentry *root)
 #ifdef CONFIG_QUOTA
 static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, 
size_t len, loff_t off);
 static ssize_t ext2_quota_write(struct super_block *sb, int type, const char 
*data, size_t len, loff_t off);
+static struct dquot **ext2_get_dquots(struct inode *inode)
+{
+   return EXT2_I(inode)-i_dquot;
+}
 #endif
 
 static const struct super_operations ext2_sops = {
@@ -320,6 +328,7 @@ static const struct super_operations ext2_sops = {
 #ifdef CONFIG_QUOTA
.quota_read = ext2_quota_read,
.quota_write= ext2_quota_write,
+   .get_dquots = ext2_get_dquots,
 #endif
 };
 
@@ -1090,6 +1099,7 @@ static int ext2_fill_super(struct super_block *sb, void 
*data, int silent)
 #ifdef CONFIG_QUOTA
sb-dq_op = dquot_operations;
sb-s_qcop = dquot_quotactl_ops;
+   sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
 #endif
 
root = ext2_iget(sb, EXT2_ROOT_INO);
-- 
1.8.1.4



[Cluster-devel] [PATCH 0/12 v4] Moving i_dquot out of struct inode

2014-11-04 Thread Jan Kara
  Hello,

  here is a new version of my patch series which moves i_dquot array from
struct inode into filesystem private part of the inode. Thus filesystems which
don't need it save 2 pointers in their inodes (would be 3 after we add project
quota support into generic quota).

The patch series also contains a change to quotactl so that each filesystem
can set quota types it supports. This is in the end unrelated change
(originally it was necessary for i_dquot moving but in the end I changed
things so that it's not anymore). I can move that into a separate series
but I was somewhat reluctant to do that since that would mean another 6
one-line patches to the same files we are changing here...

If people like the patches, I will queue this series into my tree for
the next merge window. For that I'd prefer to get acks from affected fs
maintainers (the changes are pretty trivial and I don't feel it's a must but
still I'd prefer fs maintainers to ack they are aware of the changes).

Honza

Changes since v1:
* Inode field names are now named enum
* Quota type masks now have names like QTYPE_MASK_{USR|GRP|PRJ} instead of
  opencoding shifts.

Changes since v2:
* Use -get_dquots callback instead of inode fields framework
* rebased on Linus' tree as of 3.18-rc1 + something.

Changes since v3:
* Moved bitmask of allowed quota types out of s_dquot into sb itself
* Removed pointless #ifdef CONFIG_QUOTA from OCFS2



[Cluster-devel] [PATCH 10/12] reiserfs: Convert to private i_dquot field

2014-11-04 Thread Jan Kara
CC: reiserfs-de...@vger.kernel.org
CC: Jeff Mahoney je...@suse.de
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/reiserfs/reiserfs.h |  4 
 fs/reiserfs/super.c| 11 +++
 2 files changed, 15 insertions(+)

diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
index 1894d96ccb7c..bb79cddf0a1f 100644
--- a/fs/reiserfs/reiserfs.h
+++ b/fs/reiserfs/reiserfs.h
@@ -97,6 +97,10 @@ struct reiserfs_inode_info {
 #ifdef CONFIG_REISERFS_FS_XATTR
struct rw_semaphore i_xattr_sem;
 #endif
+#ifdef CONFIG_QUOTA
+   struct dquot *i_dquot[MAXQUOTAS];
+#endif
+
struct inode vfs_inode;
 };
 
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index f1376c92cf74..ea63ab13ef92 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -594,6 +594,10 @@ static struct inode *reiserfs_alloc_inode(struct 
super_block *sb)
return NULL;
atomic_set(ei-openers, 0);
mutex_init(ei-tailpack);
+#ifdef CONFIG_QUOTA
+   memset(ei-i_dquot, 0, sizeof(ei-i_dquot));
+#endif
+
return ei-vfs_inode;
 }
 
@@ -750,6 +754,11 @@ static ssize_t reiserfs_quota_write(struct super_block *, 
int, const char *,
size_t, loff_t);
 static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t,
   loff_t);
+
+static struct dquot **reiserfs_get_dquots(struct inode *inode)
+{
+   return REISERFS_I(inode)-i_dquot;
+}
 #endif
 
 static const struct super_operations reiserfs_sops = {
@@ -768,6 +777,7 @@ static const struct super_operations reiserfs_sops = {
 #ifdef CONFIG_QUOTA
.quota_read = reiserfs_quota_read,
.quota_write = reiserfs_quota_write,
+   .get_dquots = reiserfs_get_dquots,
 #endif
 };
 
@@ -1633,6 +1643,7 @@ static int read_super_block(struct super_block *s, int 
offset)
 #ifdef CONFIG_QUOTA
s-s_qcop = reiserfs_qctl_operations;
s-dq_op = reiserfs_quota_operations;
+   s-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
 #endif
 
/*
-- 
1.8.1.4



[Cluster-devel] [PATCH 03/12] gfs2: Set allowed quota types

2014-11-04 Thread Jan Kara
We support user and group quotas. Tell vfs about it.

Acked-by: Steven Whitehouse swhit...@redhat.com
CC: cluster-devel@redhat.com
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/gfs2/ops_fstype.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index d3eae244076e..455bac77feb5 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1082,6 +1082,7 @@ static int fill_super(struct super_block *sb, struct 
gfs2_args *args, int silent
sb-s_export_op = gfs2_export_ops;
sb-s_xattr = gfs2_xattr_handlers;
sb-s_qcop = gfs2_quotactl_ops;
+   sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
sb_dqopt(sb)-flags |= DQUOT_QUOTA_SYS_FILE;
sb-s_time_gran = 1;
sb-s_maxbytes = MAX_LFS_FILESIZE;
-- 
1.8.1.4



[Cluster-devel] [PATCH 09/12] ocfs2: Convert to private i_dquot field

2014-11-04 Thread Jan Kara
CC: Mark Fasheh mfas...@suse.com
CC: Joel Becker jl...@evilplan.org
CC: ocfs2-de...@oss.oracle.com
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/ocfs2/inode.h | 2 ++
 fs/ocfs2/super.c | 8 
 2 files changed, 10 insertions(+)

diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index a9b76de46047..ca3431ee7f24 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -80,6 +80,8 @@ struct ocfs2_inode_info
 */
tid_t i_sync_tid;
tid_t i_datasync_tid;
+
+   struct dquot *i_dquot[MAXQUOTAS];
 };
 
 /*
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 93c85bc745e1..0945814ddb7b 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -143,6 +143,11 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int 
unsuspend);
 static int ocfs2_enable_quotas(struct ocfs2_super *osb);
 static void ocfs2_disable_quotas(struct ocfs2_super *osb);
 
+static struct dquot **ocfs2_get_dquots(struct inode *inode)
+{
+   return OCFS2_I(inode)-i_dquot;
+}
+
 static const struct super_operations ocfs2_sops = {
.statfs = ocfs2_statfs,
.alloc_inode= ocfs2_alloc_inode,
@@ -155,6 +160,7 @@ static const struct super_operations ocfs2_sops = {
.show_options   = ocfs2_show_options,
.quota_read = ocfs2_quota_read,
.quota_write= ocfs2_quota_write,
+   .get_dquots = ocfs2_get_dquots,
 };
 
 enum {
@@ -563,6 +569,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block 
*sb)
 
oi-i_sync_tid = 0;
oi-i_datasync_tid = 0;
+   memset(oi-i_dquot, 0, sizeof(oi-i_dquot));
 
jbd2_journal_init_jbd_inode(oi-ip_jinode, oi-vfs_inode);
return oi-vfs_inode;
@@ -2073,6 +2080,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
sb-s_export_op = ocfs2_export_ops;
sb-s_qcop = ocfs2_quotactl_ops;
sb-dq_op = ocfs2_quota_operations;
+   sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
sb-s_xattr = ocfs2_xattr_handlers;
sb-s_time_gran = 1;
sb-s_flags |= MS_NOATIME;
-- 
1.8.1.4



[Cluster-devel] [PATCH 07/12] ext3: Convert to private i_dquot field

2014-11-04 Thread Jan Kara
CC: linux-e...@vger.kernel.org
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/ext3/ext3.h  |  4 
 fs/ext3/super.c | 10 ++
 2 files changed, 14 insertions(+)

diff --git a/fs/ext3/ext3.h b/fs/ext3/ext3.h
index fc3cdcf24aed..f483a80b3fe7 100644
--- a/fs/ext3/ext3.h
+++ b/fs/ext3/ext3.h
@@ -615,6 +615,10 @@ struct ext3_inode_info {
atomic_t i_sync_tid;
atomic_t i_datasync_tid;
 
+#ifdef CONFIG_QUOTA
+   struct dquot *i_dquot[MAXQUOTAS];
+#endif
+
struct inode vfs_inode;
 };
 
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 7015db0bafd1..964e2842889d 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -485,6 +485,10 @@ static struct inode *ext3_alloc_inode(struct super_block 
*sb)
ei-vfs_inode.i_version = 1;
atomic_set(ei-i_datasync_tid, 0);
atomic_set(ei-i_sync_tid, 0);
+#ifdef CONFIG_QUOTA
+   memset(ei-i_dquot, 0, sizeof(ei-i_dquot));
+#endif
+
return ei-vfs_inode;
 }
 
@@ -764,6 +768,10 @@ static ssize_t ext3_quota_read(struct super_block *sb, int 
type, char *data,
   size_t len, loff_t off);
 static ssize_t ext3_quota_write(struct super_block *sb, int type,
const char *data, size_t len, loff_t off);
+static struct dquot **ext3_get_dquots(struct inode *inode)
+{
+   return EXT3_I(inode)-i_dquot;
+}
 
 static const struct dquot_operations ext3_quota_operations = {
.write_dquot= ext3_write_dquot,
@@ -803,6 +811,7 @@ static const struct super_operations ext3_sops = {
 #ifdef CONFIG_QUOTA
.quota_read = ext3_quota_read,
.quota_write= ext3_quota_write,
+   .get_dquots = ext3_get_dquots,
 #endif
.bdev_try_to_free_page = bdev_try_to_free_page,
 };
@@ -2008,6 +2017,7 @@ static int ext3_fill_super (struct super_block *sb, void 
*data, int silent)
 #ifdef CONFIG_QUOTA
sb-s_qcop = ext3_qctl_operations;
sb-dq_op = ext3_quota_operations;
+   sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
 #endif
memcpy(sb-s_uuid, es-s_uuid, sizeof(es-s_uuid));
INIT_LIST_HEAD(sbi-s_orphan); /* unlinked but open files */
-- 
1.8.1.4



[Cluster-devel] [PATCH 08/12] ext4: Convert to private i_dquot field

2014-11-04 Thread Jan Kara
CC: linux-e...@vger.kernel.org
CC: Theodore Ts'o ty...@mit.edu
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/ext4/ext4.h  | 4 
 fs/ext4/super.c | 8 
 2 files changed, 12 insertions(+)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index c55a1faaed58..db3f772e57ae 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -941,6 +941,10 @@ struct ext4_inode_info {
tid_t i_sync_tid;
tid_t i_datasync_tid;
 
+#ifdef CONFIG_QUOTA
+   struct dquot *i_dquot[MAXQUOTAS];
+#endif
+
/* Precomputed uuid+inum+igen checksum for seeding inode checksums */
__u32 i_csum_seed;
 };
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1eda6ab0ef9d..07ca5711cbce 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -892,6 +892,7 @@ static struct inode *ext4_alloc_inode(struct super_block 
*sb)
spin_lock_init((ei-i_block_reservation_lock));
 #ifdef CONFIG_QUOTA
ei-i_reserved_quota = 0;
+   memset(ei-i_dquot, 0, sizeof(ei-i_dquot));
 #endif
ei-jinode = NULL;
INIT_LIST_HEAD(ei-i_rsv_conversion_list);
@@ -1068,6 +1069,11 @@ static int ext4_quota_enable(struct super_block *sb, int 
type, int format_id,
 unsigned int flags);
 static int ext4_enable_quotas(struct super_block *sb);
 
+static struct dquot **ext4_get_dquots(struct inode *inode)
+{
+   return EXT4_I(inode)-i_dquot;
+}
+
 static const struct dquot_operations ext4_quota_operations = {
.get_reserved_space = ext4_get_reserved_space,
.write_dquot= ext4_write_dquot,
@@ -1117,6 +1123,7 @@ static const struct super_operations ext4_sops = {
 #ifdef CONFIG_QUOTA
.quota_read = ext4_quota_read,
.quota_write= ext4_quota_write,
+   .get_dquots = ext4_get_dquots,
 #endif
.bdev_try_to_free_page = bdev_try_to_free_page,
 };
@@ -3928,6 +3935,7 @@ static int ext4_fill_super(struct super_block *sb, void 
*data, int silent)
sb-s_qcop = ext4_qctl_sysfile_operations;
else
sb-s_qcop = ext4_qctl_operations;
+   sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
 #endif
memcpy(sb-s_uuid, es-s_uuid, sizeof(es-s_uuid));
 
-- 
1.8.1.4



[Cluster-devel] [PATCH 04/12] xfs: Set allowed quota types

2014-11-04 Thread Jan Kara
We support user, group, and project quotas. Tell VFS about it.

CC: x...@oss.sgi.com
CC: Dave Chinner da...@fromorbit.com
Signed-off-by: Jan Kara j...@suse.cz
---
 fs/xfs/xfs_super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 9f622feda6a4..206b97fd1d8a 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1425,6 +1425,7 @@ xfs_fs_fill_super(
sb-s_export_op = xfs_export_operations;
 #ifdef CONFIG_XFS_QUOTA
sb-s_qcop = xfs_quotactl_operations;
+   sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
 #endif
sb-s_op = xfs_super_operations;
 
-- 
1.8.1.4



[Cluster-devel] [PATCH 05/12] quota: Use function to provide i_dquot pointers

2014-11-04 Thread Jan Kara
i_dquot array is used by relatively few filesystems (ext?, ocfs2, jfs,
reiserfs) so it is beneficial to move this array to fs-private part of
the inode. We cannot just pass quota pointers from filesystems to quota
functions because during quotaon and quotaoff we have to traverse list
of all inodes and manipulate i_dquot pointers for each inode. So we
provide a function which generic quota code can use to get pointer to
the i_dquot array from the filesystem.

Signed-off-by: Jan Kara j...@suse.cz
---
 fs/quota/dquot.c   | 54 +++---
 include/linux/fs.h |  1 +
 2 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8a6b95e9bf3d..8144ff2b561d 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -893,6 +893,14 @@ out:
 }
 EXPORT_SYMBOL(dqget);
 
+static inline struct dquot **i_dquot(struct inode *inode)
+{
+   /* Temporary workaround until all filesystems are converted. */
+   if (!inode-i_sb-s_op-get_dquots)
+   return inode-i_dquot;
+   return inode-i_sb-s_op-get_dquots(inode);
+}
+
 static int dqinit_needed(struct inode *inode, int type)
 {
int cnt;
@@ -900,9 +908,9 @@ static int dqinit_needed(struct inode *inode, int type)
if (IS_NOQUOTA(inode))
return 0;
if (type != -1)
-   return !inode-i_dquot[type];
+   return !i_dquot(inode)[type];
for (cnt = 0; cnt  MAXQUOTAS; cnt++)
-   if (!inode-i_dquot[cnt])
+   if (!i_dquot(inode)[cnt])
return 1;
return 0;
 }
@@ -965,9 +973,9 @@ static void add_dquot_ref(struct super_block *sb, int type)
 static void remove_inode_dquot_ref(struct inode *inode, int type,
   struct list_head *tofree_head)
 {
-   struct dquot *dquot = inode-i_dquot[type];
+   struct dquot *dquot = i_dquot(inode)[type];
 
-   inode-i_dquot[type] = NULL;
+   i_dquot(inode)[type] = NULL;
if (!dquot)
return;
 
@@ -1402,7 +1410,7 @@ static void __dquot_initialize(struct inode *inode, int 
type)
 * we check it without locking here to avoid unnecessary
 * dqget()/dqput() calls.
 */
-   if (inode-i_dquot[cnt])
+   if (i_dquot(inode)[cnt])
continue;
init_needed = 1;
 
@@ -1433,8 +1441,8 @@ static void __dquot_initialize(struct inode *inode, int 
type)
/* We could race with quotaon or dqget() could have failed */
if (!got[cnt])
continue;
-   if (!inode-i_dquot[cnt]) {
-   inode-i_dquot[cnt] = got[cnt];
+   if (!i_dquot(inode)[cnt]) {
+   i_dquot(inode)[cnt] = got[cnt];
got[cnt] = NULL;
/*
 * Make quota reservation system happy if someone
@@ -1442,7 +1450,7 @@ static void __dquot_initialize(struct inode *inode, int 
type)
 */
rsv = inode_get_rsv_space(inode);
if (unlikely(rsv))
-   dquot_resv_space(inode-i_dquot[cnt], rsv);
+   dquot_resv_space(i_dquot(inode)[cnt], rsv);
}
}
 out_err:
@@ -1472,8 +1480,8 @@ static void __dquot_drop(struct inode *inode)
 
spin_lock(dq_data_lock);
for (cnt = 0; cnt  MAXQUOTAS; cnt++) {
-   put[cnt] = inode-i_dquot[cnt];
-   inode-i_dquot[cnt] = NULL;
+   put[cnt] = i_dquot(inode)[cnt];
+   i_dquot(inode)[cnt] = NULL;
}
spin_unlock(dq_data_lock);
dqput_all(put);
@@ -1494,7 +1502,7 @@ void dquot_drop(struct inode *inode)
 * add quota pointers back anyway.
 */
for (cnt = 0; cnt  MAXQUOTAS; cnt++) {
-   if (inode-i_dquot[cnt])
+   if (i_dquot(inode)[cnt])
break;
}
 
@@ -1595,7 +1603,7 @@ int __dquot_alloc_space(struct inode *inode, qsize_t 
number, int flags)
 {
int cnt, ret = 0, index;
struct dquot_warn warn[MAXQUOTAS];
-   struct dquot **dquots = inode-i_dquot;
+   struct dquot **dquots = i_dquot(inode);
int reserve = flags  DQUOT_SPACE_RESERVE;
 
if (!dquot_active(inode)) {
@@ -1647,7 +1655,7 @@ int dquot_alloc_inode(struct inode *inode)
 {
int cnt, ret = 0, index;
struct dquot_warn warn[MAXQUOTAS];
-   struct dquot * const *dquots = inode-i_dquot;
+   struct dquot * const *dquots = i_dquot(inode);
 
if (!dquot_active(inode))
return 0;
@@ -1696,14 +1704,14 @@ int dquot_claim_space_nodirty(struct inode *inode, 
qsize_t number)
spin_lock(dq_data_lock);
/* Claim reserved quotas to allocated quotas */
for (cnt = 0; cnt  MAXQUOTAS; cnt++) {
-  

Re: [Cluster-devel] [RFA][PATCH 5/8] dlm: Remove seq_printf() return checks and use seq_has_overflowed()

2014-11-04 Thread Steven Rostedt
On Wed, 29 Oct 2014 17:56:07 -0400
Steven Rostedt rost...@goodmis.org wrote:

 From: Joe Perches j...@perches.com
 
 [ REQUEST FOR ACKS ]

Can any of the DLM maintainers give me an Acked-by for this?

Thanks!

-- Steve

 
 The seq_printf() return is going away soon and users of it should
 check seq_has_overflowed() to see if the buffer is full and will
 not accept any more data.
 
 Convert functions returning int to void where seq_printf() is used.
 
 Link: 
 http://lkml.kernel.org/p/43590057bcb83846acbbcc1fe641f792b2fb7773.1412031505.git@perches.com
 
 Cc: Christine Caulfield ccaul...@redhat.com
 Cc: David Teigland teigl...@redhat.com
 Cc: cluster-devel@redhat.com
 Signed-off-by: Joe Perches j...@perches.com
 Signed-off-by: Steven Rostedt rost...@goodmis.org
 ---
  fs/dlm/debug_fs.c | 251 
 +-
  1 file changed, 117 insertions(+), 134 deletions(-)
 
 diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
 index 1323c568e362..3bf460894088 100644
 --- a/fs/dlm/debug_fs.c
 +++ b/fs/dlm/debug_fs.c
 @@ -48,8 +48,8 @@ static char *print_lockmode(int mode)
   }
  }
  
 -static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
 -   struct dlm_rsb *res)
 +static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
 +struct dlm_rsb *res)
  {
   seq_printf(s, %08x %s, lkb-lkb_id, print_lockmode(lkb-lkb_grmode));
  
 @@ -68,21 +68,17 @@ static int print_format1_lock(struct seq_file *s, struct 
 dlm_lkb *lkb,
   if (lkb-lkb_wait_type)
   seq_printf(s,  wait_type: %d, lkb-lkb_wait_type);
  
 - return seq_puts(s, \n);
 + seq_puts(s, \n);
  }
  
 -static int print_format1(struct dlm_rsb *res, struct seq_file *s)
 +static void print_format1(struct dlm_rsb *res, struct seq_file *s)
  {
   struct dlm_lkb *lkb;
   int i, lvblen = res-res_ls-ls_lvblen, recover_list, root_list;
 - int rv;
  
   lock_rsb(res);
  
 - rv = seq_printf(s, \nResource %p Name (len=%d) \,
 - res, res-res_length);
 - if (rv)
 - goto out;
 + seq_printf(s, \nResource %p Name (len=%d) \, res, res-res_length);
  
   for (i = 0; i  res-res_length; i++) {
   if (isprint(res-res_name[i]))
 @@ -92,17 +88,16 @@ static int print_format1(struct dlm_rsb *res, struct 
 seq_file *s)
   }
  
   if (res-res_nodeid  0)
 - rv = seq_printf(s, \\nLocal Copy, Master is node %d\n,
 - res-res_nodeid);
 + seq_printf(s, \\nLocal Copy, Master is node %d\n,
 +res-res_nodeid);
   else if (res-res_nodeid == 0)
 - rv = seq_puts(s, \\nMaster Copy\n);
 + seq_puts(s, \\nMaster Copy\n);
   else if (res-res_nodeid == -1)
 - rv = seq_printf(s, \\nLooking up master (lkid %x)\n,
 - res-res_first_lkid);
 + seq_printf(s, \\nLooking up master (lkid %x)\n,
 +res-res_first_lkid);
   else
 - rv = seq_printf(s, \\nInvalid master %d\n,
 - res-res_nodeid);
 - if (rv)
 + seq_printf(s, \\nInvalid master %d\n, res-res_nodeid);
 + if (seq_has_overflowed(s))
   goto out;
  
   /* Print the LVB: */
 @@ -116,8 +111,8 @@ static int print_format1(struct dlm_rsb *res, struct 
 seq_file *s)
   }
   if (rsb_flag(res, RSB_VALNOTVALID))
   seq_puts(s,  (INVALID));
 - rv = seq_puts(s, \n);
 - if (rv)
 + seq_puts(s, \n);
 + if (seq_has_overflowed(s))
   goto out;
   }
  
 @@ -125,32 +120,30 @@ static int print_format1(struct dlm_rsb *res, struct 
 seq_file *s)
   recover_list = !list_empty(res-res_recover_list);
  
   if (root_list || recover_list) {
 - rv = seq_printf(s, Recovery: root %d recover %d flags %lx 
 - count %d\n, root_list, recover_list,
 - res-res_flags, res-res_recover_locks_count);
 - if (rv)
 - goto out;
 + seq_printf(s, Recovery: root %d recover %d flags %lx count 
 %d\n,
 +root_list, recover_list,
 +res-res_flags, res-res_recover_locks_count);
   }
  
   /* Print the locks attached to this resource */
   seq_puts(s, Granted Queue\n);
   list_for_each_entry(lkb, res-res_grantqueue, lkb_statequeue) {
 - rv = print_format1_lock(s, lkb, res);
 - if (rv)
 + print_format1_lock(s, lkb, res);
 + if (seq_has_overflowed(s))
   goto out;
   }
  
   seq_puts(s, Conversion Queue\n);
   list_for_each_entry(lkb, res-res_convertqueue, lkb_statequeue) {
 - rv = print_format1_lock(s, lkb, res);
 - if (rv)
 +  

Re: [Cluster-devel] [RFA][PATCH 6/8] dlm: Use seq_puts() instead of seq_printf() for constant strings

2014-11-04 Thread Steven Rostedt
On Wed, 29 Oct 2014 17:56:08 -0400
Steven Rostedt rost...@goodmis.org wrote:

 From: Joe Perches j...@perches.com
 
 [ REQUEST FOR ACKS ]

Can any of the DLM maintainers give me an Acked-by for this?

Thanks!

-- Steve

 
 Convert the seq_printf output with constant strings to seq_puts.
 
 Link: 
 http://lkml.kernel.org/p/b416b016f4a6e49115ba736cad6ea2709a8bc1c4.1412031505.git@perches.com
 
 Cc: Christine Caulfield ccaul...@redhat.com
 Cc: David Teigland teigl...@redhat.com
 Cc: cluster-devel@redhat.com
 Signed-off-by: Joe Perches j...@perches.com
 Signed-off-by: Steven Rostedt rost...@goodmis.org
 ---
  fs/dlm/debug_fs.c | 12 +---
  1 file changed, 5 insertions(+), 7 deletions(-)
 
 diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
 index 3bf460894088..eea64912c9c0 100644
 --- a/fs/dlm/debug_fs.c
 +++ b/fs/dlm/debug_fs.c
 @@ -279,7 +279,7 @@ static void print_format3(struct dlm_rsb *r, struct 
 seq_file *s)
   print_name = 0;
   }
  
 - seq_printf(s, %s, print_name ? str  : hex);
 + seq_puts(s, print_name ? str  : hex);
  
   for (i = 0; i  r-res_length; i++) {
   if (print_name)
 @@ -353,7 +353,7 @@ static void print_format4(struct dlm_rsb *r, struct 
 seq_file *s)
   print_name = 0;
   }
  
 - seq_printf(s, %s, print_name ? str  : hex);
 + seq_puts(s, print_name ? str  : hex);
  
   for (i = 0; i  r-res_length; i++) {
   if (print_name)
 @@ -390,23 +390,21 @@ static int table_seq_show(struct seq_file *seq, void 
 *iter_ptr)
   break;
   case 2:
   if (ri-header) {
 - seq_printf(seq, id nodeid remid pid xid exflags 
 - flags sts grmode rqmode time_ms 
 - r_nodeid r_len r_name\n);
 + seq_puts(seq, id nodeid remid pid xid exflags flags 
 sts grmode rqmode time_ms r_nodeid r_len r_name\n);
   ri-header = 0;
   }
   print_format2(ri-rsb, seq);
   break;
   case 3:
   if (ri-header) {
 - seq_printf(seq, version rsb 1.1 lvb 1.1 lkb 1.1\n);
 + seq_puts(seq, version rsb 1.1 lvb 1.1 lkb 1.1\n);
   ri-header = 0;
   }
   print_format3(ri-rsb, seq);
   break;
   case 4:
   if (ri-header) {
 - seq_printf(seq, version 4 rsb 2\n);
 + seq_puts(seq, version 4 rsb 2\n);
   ri-header = 0;
   }
   print_format4(ri-rsb, seq);



Re: [Cluster-devel] [PATCH 11/12] jfs: Convert to private i_dquot field

2014-11-04 Thread Dave Kleikamp
On 11/04/2014 05:19 AM, Jan Kara wrote:

 CC: jfs-discuss...@lists.sourceforge.net
 Signed-off-by: Jan Kara j...@suse.cz

Acked-by: Dave Kleikamp dave.kleik...@oracle.com

 ---
  fs/jfs/jfs_incore.h | 3 +++
  fs/jfs/super.c  | 9 +
  2 files changed, 12 insertions(+)
 
 diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
 index cf47f09e8ac8..fa7e795bd8ae 100644
 --- a/fs/jfs/jfs_incore.h
 +++ b/fs/jfs/jfs_incore.h
 @@ -94,6 +94,9 @@ struct jfs_inode_info {
   unchar _inline_ea[128]; /* 128: inline extended attr */
   } link;
   } u;
 +#ifdef CONFIG_QUOTA
 + struct dquot *i_dquot[MAXQUOTAS];
 +#endif
   u32 dev;/* will die when we get wide dev_t */
   struct inodevfs_inode;
  };
 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
 index 93e897e588a8..16c3a9556634 100644
 --- a/fs/jfs/super.c
 +++ b/fs/jfs/super.c
 @@ -117,6 +117,9 @@ static struct inode *jfs_alloc_inode(struct super_block 
 *sb)
   jfs_inode = kmem_cache_alloc(jfs_inode_cachep, GFP_NOFS);
   if (!jfs_inode)
   return NULL;
 +#ifdef CONFIG_QUOTA
 + memset(jfs_inode-i_dquot, 0, sizeof(jfs_inode-i_dquot));
 +#endif
   return jfs_inode-vfs_inode;
  }
  
 @@ -537,6 +540,7 @@ static int jfs_fill_super(struct super_block *sb, void 
 *data, int silent)
  #ifdef CONFIG_QUOTA
   sb-dq_op = dquot_operations;
   sb-s_qcop = dquot_quotactl_ops;
 + sb-s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
  #endif
  
   /*
 @@ -836,6 +840,10 @@ out:
   return len - towrite;
  }
  
 +static struct dquot **jfs_get_dquots(struct inode *inode)
 +{
 + return JFS_IP(inode)-i_dquot;
 +}
  #endif
  
  static const struct super_operations jfs_super_operations = {
 @@ -854,6 +862,7 @@ static const struct super_operations jfs_super_operations 
 = {
  #ifdef CONFIG_QUOTA
   .quota_read = jfs_quota_read,
   .quota_write= jfs_quota_write,
 + .get_dquots = jfs_get_dquots,
  #endif
  };
  
 



Re: [Cluster-devel] [PATCH 08/12] ext4: Convert to private i_dquot field

2014-11-04 Thread Theodore Ts'o
On Tue, Nov 04, 2014 at 12:19:49PM +0100, Jan Kara wrote:
 CC: linux-e...@vger.kernel.org
 CC: Theodore Ts'o ty...@mit.edu
 Signed-off-by: Jan Kara j...@suse.cz

Acked-by: Theodore Ts'o ty...@mit.edu

- Ted



Re: [Cluster-devel] [RFA][PATCH 5/8] dlm: Remove seq_printf() return checks and use seq_has_overflowed()

2014-11-04 Thread David Teigland
On Tue, Nov 04, 2014 at 08:08:52AM -0500, Steven Rostedt wrote:
 On Wed, 29 Oct 2014 17:56:07 -0400
 Steven Rostedt rost...@goodmis.org wrote:
 
  From: Joe Perches j...@perches.com
  
  [ REQUEST FOR ACKS ]
 
 Can any of the DLM maintainers give me an Acked-by for this?

Looks ok,
Dave