Whamcloud - gitweb
LU-10040 nodemap: add nodemap idmap correctly 64/29364/10
authorEmoly Liu <emoly.liu@intel.com>
Thu, 9 Nov 2017 08:23:48 +0000 (16:23 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 22 Nov 2017 03:54:43 +0000 (03:54 +0000)
commit253ccbd55ffe7fcdc405c9fcc4f72a47578920fe
tree01874980609b26c5c9d89215258c77171e392326
parenta861f8deb4d064a5835c3ba81a756aace625b88c
LU-10040 nodemap: add nodemap idmap correctly

There are 3 situations when adding an idmap {id_client:id_fs} to
a nodemap tree:
 - both id_client and id_fs are matched, that means this idmap
   already exists, so return -EEXIT;
 - neither id_client nor id_fs is matched, that means this is a
   new idmap, so insert it;
 - only "id_client" or "id_fs" is matched, since idmap uses
   "id_client" as index key, we need to delete that old idmap and
   its index by its id_client, and then insert it again. In the
   original implementation, idmap_insert() calls rb_replace_node()
   to replace the old idmap without re-sorting its both id_client
   and id_fs, so that this new added idmap can't be found by
   idmap_search() due to its wrong left and right nodes, and can't
   be deleted either.

Also, this patch improves the following code:
 - nm_idmap_lock: use type rw_semaphore instead of rwlock, because
   nodemap_idx_idmap_del() may sleep on FS operations while this
   lock is being held.
 - Add "update_idmaps" to sanity-sec.sh test_15 to verify this fix,
   and improve other part of this test case as well to make it run
   correctly.

Test-Parameters: testlist=sanity-sec
Signed-off-by: Stephan Thiell <sthiell@stanford.edu>
Signed-off-by: Emoly Liu <emoly.liu@intel.com>
Change-Id: Icf777f14c2e1dd56fa5cd0eb56666240e206d199
Reviewed-on: https://review.whamcloud.com/29364
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre_nodemap.h
lustre/ptlrpc/nodemap_handler.c
lustre/ptlrpc/nodemap_idmap.c
lustre/ptlrpc/nodemap_internal.h
lustre/ptlrpc/nodemap_lproc.c
lustre/tests/sanity-sec.sh