From c95db3046c672473611d9ac0ab6cd93bd8211347 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 15 Mar 2013 10:34:45 +0100 Subject: store: Add (un)locking functionality Some configuration/cache files (like the NFS rmtab) can be stored on a GlusterFS volume and be used by multiple storage servers. This requires suitable locking for the gf_store_handle_t structure. Introduce gf_store_lock() and gf_store_unlock() for this purpose. The gf_store_locked_local() function can be used to check if the gf_store_handle_t has been locked by the current process. This change also includes an unrelated correction where a FILE* was getting leaked. Krishnan Parthasarathi identified this while reviewing the new locking functionality. Change-Id: I431b7510801841d4bad64480b4bb99d87e2ad347 BUG: 904065 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/4677 Reviewed-by: Rajesh Joseph Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/store.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libglusterfs/src/store.h') diff --git a/libglusterfs/src/store.h b/libglusterfs/src/store.h index 4fe432e56de..337103ff73e 100644 --- a/libglusterfs/src/store.h +++ b/libglusterfs/src/store.h @@ -21,6 +21,7 @@ struct gf_store_handle_ { char *path; int fd; FILE *read; + int locked; /* state of lockf() */ }; typedef struct gf_store_handle_ gf_store_handle_t; @@ -99,4 +100,13 @@ gf_store_iter_destroy (gf_store_iter_t *iter); char* gf_store_strerror (gf_store_op_errno_t op_errno); +int +gf_store_lock (gf_store_handle_t *sh); + +void +gf_store_unlock (gf_store_handle_t *sh); + +int +gf_store_locked_local (gf_store_handle_t *sh); + #endif -- cgit