summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/src/marker-quota.h
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2011-05-08 23:41:23 +0000
committerAnand Avati <avati@gluster.com>2011-07-20 06:12:42 -0700
commite559ea5f8056472a6df8fde942239cb6342dc23e (patch)
treef781e2ac4e2381f3f245dcbf4afeae3607995f0f /xlators/features/marker/src/marker-quota.h
parentfd60df8798b74ea2a9c793798d4ad2ab3fbf9394 (diff)
features/marker: fix race-conditions, memory corruptions and fd-leaks.
- remove xattrs from newpath after rename is complete. - hold inodelk on both parents (if they are different) before doing rename and gather contribution values of oldpath and newpath to their parents while still holding the locks. Use these contribution values to reduce parent sizes. - performance optimization: abort updation process if delta is zero. - libglusterfs/call-stub: Allow unwinding of frames for rename during call_resume_unwind. - fixes in dirty inode healing codepath: - fix fd-leak of fd opened on the directory. - don't add (instead just assign) next offset at which readdir has to be sent to local->d_off. - assign to local->d_off before winding lookup call to get child contribution. - use mutexes while accessing contribution values stored in inode context. - use contribution values from backend instead of in-memory while reducing parent sizes during rename - wipe parent_loc in marker_local_unref. - check for refcount being zero holding lock in quota_local_unref. - hold parent inodelk during creation of xattrs on directory. - use contribution value to reduce parent's size, if the value to be subtracted is not passed as argument to reduce_parent_size. - skip contribution creation on root. Change-Id: I97a9ac7efc5cf82abd3837fa6f9766c35676a908 BUG: 2697 Signed-off-by: Junaid <junaid@gluster.com> Reviewed-on: http://review.gluster.com/31 Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/marker/src/marker-quota.h')
-rw-r--r--xlators/features/marker/src/marker-quota.h58
1 files changed, 26 insertions, 32 deletions
diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h
index ea54bb6315c..34e8dfd81bd 100644
--- a/xlators/features/marker/src/marker-quota.h
+++ b/xlators/features/marker/src/marker-quota.h
@@ -53,7 +53,7 @@ char volname [40];
do { \
ret = 0; \
var = GF_CALLOC (sizeof (type), 1, \
- gf_marker_mt_##type); \
+ gf_marker_mt_##type); \
if (!var) { \
gf_log ("", GF_LOG_ERROR, \
"out of memory"); \
@@ -64,7 +64,7 @@ char volname [40];
#define QUOTA_ALLOC_OR_GOTO(var, type, ret, label) \
do { \
var = GF_CALLOC (sizeof (type), 1, \
- gf_marker_mt_##type); \
+ gf_marker_mt_##type); \
if (!var) { \
gf_log ("", GF_LOG_ERROR, \
"out of memory"); \
@@ -74,42 +74,35 @@ char volname [40];
ret = 0; \
} while (0);
-#define GET_CONTRI_KEY(var, _gfid, _ret) \
- do { \
- char _gfid_unparsed[40]; \
- uuid_unparse (_gfid, _gfid_unparsed); \
+#define GET_CONTRI_KEY(var, _gfid, _ret) \
+ do { \
+ char _gfid_unparsed[40]; \
+ uuid_unparse (_gfid, _gfid_unparsed); \
_ret = snprintf (var, CONTRI_KEY_MAX, QUOTA_XATTR_PREFIX \
- ".%s.%s." CONTRIBUTION, VOL_NAME, \
- _gfid_unparsed); \
+ ".%s.%s." CONTRIBUTION, VOL_NAME, \
+ _gfid_unparsed); \
} while (0);
-#define QUOTA_SAFE_INCREMENT(lock, var) \
- do { \
- LOCK (lock); \
- var ++; \
- UNLOCK (lock); \
- } while (0)
-
-#define QUOTA_SAFE_DECREMENT(lock, var) \
- do { \
- LOCK (lock); \
- var --; \
- UNLOCK (lock); \
+#define QUOTA_SAFE_INCREMENT(lock, var) \
+ do { \
+ LOCK (lock); \
+ var ++; \
+ UNLOCK (lock); \
} while (0)
-
struct quota_inode_ctx {
- int64_t size;
- int8_t dirty;
- gf_lock_t lock;
- struct list_head contribution_head;
+ int64_t size;
+ int8_t dirty;
+ gf_lock_t lock;
+ struct list_head contribution_head;
};
typedef struct quota_inode_ctx quota_inode_ctx_t;
struct inode_contribution {
struct list_head contri_list;
- int64_t contribution;
- uuid_t gfid;
+ int64_t contribution;
+ uuid_t gfid;
+ gf_lock_t lock;
};
typedef struct inode_contribution inode_contribution_t;
@@ -119,15 +112,16 @@ struct quota_local {
int32_t err;
int32_t ref;
int64_t sum;
+ int64_t size;
int32_t hl_count;
int32_t dentry_child_count;
- fd_t *fd;
+ fd_t *fd;
call_frame_t *frame;
- gf_lock_t lock;
+ gf_lock_t lock;
- loc_t loc;
- loc_t parent_loc;
+ loc_t loc;
+ loc_t parent_loc;
quota_inode_ctx_t *ctx;
inode_contribution_t *contri;
@@ -157,7 +151,7 @@ quota_dirty_inode_readdir (call_frame_t *, void *, xlator_t *,
int32_t, int32_t, fd_t *);
int32_t
-reduce_parent_size (xlator_t *, loc_t *);
+reduce_parent_size (xlator_t *, loc_t *, int64_t);
int32_t
quota_rename_update_newpath (xlator_t *, loc_t *);