Whamcloud - gitweb
LU-9855 lustre: replace LPROCFS_CLIMP_CHECK() 56/36956/6
authorMr NeilBrown <neilb@suse.de>
Mon, 9 Dec 2019 05:33:46 +0000 (16:33 +1100)
committerOleg Drokin <green@whamcloud.com>
Fri, 14 Feb 2020 05:50:44 +0000 (05:50 +0000)
commitf4ce6b568b523060e71b17cf679c2b99d0038dbc
treee0b8e916ecd4f95e258582df28b447791d4181a8
parent0323f0b021aa7732fd1490f97bd9e61de365c599
LU-9855 lustre: replace LPROCFS_CLIMP_CHECK()

The usage pattern for LPROCFS_CLIMP_CHECK() is clumsy.
It must be paired with LPROCFS_CLIMP_EXIT(), but
not doing this does not produce a compile-time error.
The 'import' should not be dereferenced before the CHECK, or
used after the EXIT, but sometimes it is.

Replace it with a structure macro/statement:

 with_obd_imp_lock(obd, imp, rc) {
     statements;
 }

statements are protected by the semaphore and only run if imp can be
set to a non-NULL pointer.
rc can be changed by the statements, and should be returned
afterwards as it may have been set to -ENODEV.

Errors fixed with this patch:
- some code tested u.cli.cl_import no-NULL even after
  LPROCFS_CLIMP_CHECK()
- some code dereferences cl_import before calling
  LPROCFS_CLIMP_CHECK()
- short_io_bytes_store() and max_procs_in_flight_store() don't access
  the import, so don't need LPROCFS_CLIMP_CHECK
- lprocfs_import_seq_write() set count to an error before 'goto out'
  which would free memory of length "count+1".
- lprocfs_import_seq_write() also called ptlrpc_recover_import()
  on the imp *after* dropping the semaphore.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: If9d5eb452157d7f76796f690569ef13fec111d76
Reviewed-on: https://review.whamcloud.com/36956
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lprocfs_status.h
lustre/mdc/lproc_mdc.c
lustre/mgc/mgc_request.c
lustre/obdclass/lprocfs_status.c
lustre/osc/lproc_osc.c
lustre/osp/lproc_osp.c
lustre/ptlrpc/lproc_ptlrpc.c