LU-2988 mgs: Fix two "lctl replace_nids" resource leaks
When conf-sanity 66 was run on a single machine, it failed to remove
some Lustre kernel modules in the cleanup phase:
Modules still loaded:
ldiskfs/ldiskfs/ldiskfs.o lustre/mdd/mdd.o lustre/mgs/mgs.o
lustre/quota/lquota.o lustre/mgc/mgc.o lustre/fid/fid.o
lustre/fld/fld.o lustre/ptlrpc/ptlrpc.o lustre/obdclass/obdclass.o
lustre/lvfs/lvfs.o lnet/klnds/socklnd/ksocklnd.o lnet/lnet/lnet.o
libcfs/libcfs/libcfs.o
Some simple experiments quickly narrowed down the bad guy to the first
"lctl replace_nids" command. In mgs_iocontrol(), the
OBD_IOC_REPLACE_NIDS case does not destroy the lu_env, which
references several Lustre kernel modules via the keys. This patch
fixes the leak by replacing "RETURN(rc)" with "break".
Local testing revealed another issue, however, after the first issue
was fixed. unload_modules() complained about a memory leak after
removing all modules:
LustreError: 14530:0:(class_obd.c:701:cleanup_obdclass()) obd_memory
max:
28770011, leaked:
18446744073709551608
The leaked number is clearly suspicious. It turned out that
mgs_replace_nids_log() frees more memory, with regard to accounting,
than it allocates. This patch also fixes the fake leak.
To prevent regressions, this patch adds error checking to the
cleanup() call in conf-sanity 66.
Change-Id: Ia3b1531b558a2a12947ff9a783b383962ae5da78
Signed-off-by: Li Wei <wei.g.li@intel.com>
Reviewed-on: http://review.whamcloud.com/5765
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Artem Blagodarenko <artem_blagodarenko@xyratex.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>