summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/src/marker-quota.h
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-03-17 20:05:19 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-17 21:07:04 -0700
commit7970183f4c730d4aca3cfaa106fde015a0fbc415 (patch)
treebe48e8390e3acc8468061f95785b943a14c43ced /xlators/features/marker/src/marker-quota.h
parent33bb32ce5866a15e7d5164c67f214c4797236066 (diff)
Quota/marker : Support for inode quota
Currently, the only way to retrieve the number of files/objects in a directory or volume is to do a crawl of the entire directory/volume. This is expensive and is not scalable. The new mechanism proposes to store count of objects/files as part of an extended attribute of a directory. Each directory's extended attribute value will indicate the number of files/objects present in a tree with the directory being considered as the root of the tree. Currently file usage is accounted in marker by doing multiple FOPs like setting and getting xattrs. Doing this with STACK WIND and UNWIND can be harder to debug as involves multiple callbacks. In this code we are replacing current mechanism with syncop approach as syncop code is much simpler to follow and help us implement inode quota in an organized way. Change-Id: Ibf366fbe07037284e89a241ddaff7750fc8771b4 BUG: 1188636 Signed-off-by: vmallika <vmallika@redhat.com> Signed-off-by: Sachin Pandit <spandit@redhat.com> Reviewed-on: http://review.gluster.org/9567 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features/marker/src/marker-quota.h')
-rw-r--r--xlators/features/marker/src/marker-quota.h62
1 files changed, 46 insertions, 16 deletions
diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h
index 42def9d22dc..fa132a815b7 100644
--- a/xlators/features/marker/src/marker-quota.h
+++ b/xlators/features/marker/src/marker-quota.h
@@ -21,7 +21,7 @@
#define QUOTA_XATTR_PREFIX "trusted.glusterfs"
#define QUOTA_DIRTY_KEY "trusted.glusterfs.quota.dirty"
-#define CONTRIBUTION "contri"
+#define CONTRIBUTION "contri"
#define CONTRI_KEY_MAX 512
#define READDIR_BUF 4096
@@ -59,21 +59,21 @@
ret = 0; \
} while (0);
-#define GET_CONTRI_KEY(var, _gfid, _ret) \
- do { \
- if (_gfid != NULL) { \
- char _gfid_unparsed[40]; \
- uuid_unparse (_gfid, _gfid_unparsed); \
- _ret = snprintf (var, CONTRI_KEY_MAX, \
- QUOTA_XATTR_PREFIX \
+#define GET_CONTRI_KEY(var, _gfid, _ret) \
+ do { \
+ if (_gfid != NULL) { \
+ char _gfid_unparsed[40]; \
+ uuid_unparse (_gfid, _gfid_unparsed); \
+ _ret = snprintf (var, CONTRI_KEY_MAX, \
+ QUOTA_XATTR_PREFIX \
".%s.%s." CONTRIBUTION, "quota", \
- _gfid_unparsed); \
- } else { \
- _ret = snprintf (var, CONTRI_KEY_MAX, \
- QUOTA_XATTR_PREFIX \
- ".%s.." CONTRIBUTION, "quota"); \
- } \
- } while (0);
+ _gfid_unparsed); \
+ } else { \
+ _ret = snprintf (var, CONTRI_KEY_MAX, \
+ QUOTA_XATTR_PREFIX \
+ ".%s.." CONTRIBUTION, "quota"); \
+ } \
+ } while (0)
#define QUOTA_SAFE_INCREMENT(lock, var) \
do { \
@@ -84,6 +84,8 @@
struct quota_inode_ctx {
int64_t size;
+ int64_t file_count;
+ int64_t dir_count;
int8_t dirty;
gf_boolean_t updation_status;
gf_lock_t lock;
@@ -91,9 +93,28 @@ struct quota_inode_ctx {
};
typedef struct quota_inode_ctx quota_inode_ctx_t;
+struct quota_meta {
+ int64_t size;
+ int64_t file_count;
+ int64_t dir_count;
+};
+typedef struct quota_meta quota_meta_t;
+
+struct quota_synctask {
+ xlator_t *this;
+ loc_t loc;
+ dict_t *dict;
+ struct iatt buf;
+ int64_t contri;
+ gf_boolean_t is_static;
+};
+typedef struct quota_synctask quota_synctask_t;
+
struct inode_contribution {
struct list_head contri_list;
int64_t contribution;
+ int64_t file_count;
+ int64_t dir_count;
uuid_t gfid;
gf_lock_t lock;
};
@@ -103,7 +124,7 @@ int32_t
mq_get_lock_on_parent (call_frame_t *, xlator_t *);
int32_t
-mq_req_xattr (xlator_t *, loc_t *, dict_t *);
+mq_req_xattr (xlator_t *, loc_t *, dict_t *, char *);
int32_t
init_quota_priv (xlator_t *);
@@ -117,6 +138,12 @@ mq_set_inode_xattr (xlator_t *, loc_t *);
int
mq_initiate_quota_txn (xlator_t *, loc_t *);
+int
+mq_initiate_quota_blocking_txn (xlator_t *, loc_t *);
+
+int
+mq_create_xattrs_txn (xlator_t *this, loc_t *loc);
+
int32_t
mq_dirty_inode_readdir (call_frame_t *, void *, xlator_t *,
int32_t, int32_t, fd_t *, dict_t *);
@@ -125,6 +152,9 @@ int32_t
mq_reduce_parent_size (xlator_t *, loc_t *, int64_t);
int32_t
+mq_reduce_parent_size_txn (xlator_t *, loc_t *, int64_t);
+
+int32_t
mq_rename_update_newpath (xlator_t *, loc_t *);
int32_t