linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Oleg Drokin <oleg.drokin@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	James Simmons <jsimmons@infradead.org>,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [PATCH 12/30] staging: lustre: discard cfs_block_sigsinv()
Date: Mon, 21 May 2018 14:35:12 +1000	[thread overview]
Message-ID: <152687731280.24196.2550193187633714376.stgit@noble> (raw)
In-Reply-To: <152687724799.24196.7718555295926047576.stgit@noble>

cfs_block_sigsinv() and cfs_restore_sigs() are simple
wrappers which save a couple of line of code and
hurt readability for people not familiar with them.
They aren't used often enough to be worthwhile,
so discard them and open-code the functionality.

The sigorsets() call isn't needed as or-ing with current->blocked is
exactly what sigprocmask(SIG_BLOCK) does.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   16 ---------------
 drivers/staging/lustre/lustre/include/lustre_lib.h |   21 +++++++++++---------
 drivers/staging/lustre/lustre/llite/llite_mmap.c   |   14 ++++++++-----
 3 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index be40cf4fb44a..d9002e7424d4 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -93,22 +93,6 @@
 #define LNET_ACCEPTOR_MIN_RESERVED_PORT    512
 #define LNET_ACCEPTOR_MAX_RESERVED_PORT    1023
 
-/* Block all signals except for the @sigs */
-static inline void cfs_block_sigsinv(unsigned long sigs, sigset_t *old)
-{
-	sigset_t new;
-
-	siginitsetinv(&new, sigs);
-	sigorsets(&new, &current->blocked, &new);
-	sigprocmask(SIG_BLOCK, &new, old);
-}
-
-static inline void
-cfs_restore_sigs(sigset_t *old)
-{
-	sigprocmask(SIG_SETMASK, old, NULL);
-}
-
 struct libcfs_ioctl_handler {
 	struct list_head item;
 	int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h
index 0053eafc1c10..eec10827f51f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_lib.h
+++ b/drivers/staging/lustre/lustre/include/lustre_lib.h
@@ -94,31 +94,34 @@ static inline int l_fatal_signal_pending(struct task_struct *p)
  */
 #define l_wait_event_abortable(wq, condition)				\
 ({									\
-	sigset_t __old_blocked;						\
+	sigset_t __new_blocked, __old_blocked;				\
 	int __ret = 0;							\
-	cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);		\
+	siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);			\
+	sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked);		\
 	__ret = wait_event_interruptible(wq, condition);		\
-	cfs_restore_sigs(&__old_blocked);				\
+	sigprocmask(SIG_SETMASK, &__old_blocked, NULL);			\
 	__ret;								\
 })
 
 #define l_wait_event_abortable_timeout(wq, condition, timeout)		\
 ({									\
-	sigset_t __old_blocked;						\
+	sigset_t __new_blocked, __old_blocked;				\
 	int __ret = 0;							\
-	cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);		\
+	siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);			\
+	sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked);		\
 	__ret = wait_event_interruptible_timeout(wq, condition, timeout);\
-	cfs_restore_sigs(&__old_blocked);				\
+	sigprocmask(SIG_SETMASK, &__old_blocked, NULL);			\
 	__ret;								\
 })
 
 #define l_wait_event_abortable_exclusive(wq, condition)			\
 ({									\
-	sigset_t __old_blocked;						\
+	sigset_t __new_blocked, __old_blocked;				\
 	int __ret = 0;							\
-	cfs_block_sigsinv(LUSTRE_FATAL_SIGS, &__old_blocked);		\
+	siginitset(&__new_blocked, LUSTRE_FATAL_SIGS);			\
+	sigprocmask(SIG_BLOCK, &__new_blocked, &__old_blocked);		\
 	__ret = wait_event_interruptible_exclusive(wq, condition);	\
-	cfs_restore_sigs(&__old_blocked);				\
+	sigprocmask(SIG_SETMASK, &__old_blocked, NULL);			\
 	__ret;								\
 })
 #endif /* _LUSTRE_LIB_H */
diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c
index 214b07554e62..d7fb5533f707 100644
--- a/drivers/staging/lustre/lustre/llite/llite_mmap.c
+++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c
@@ -152,7 +152,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
 	struct vvp_io	   *vio;
 	int		      result;
 	u16 refcheck;
-	sigset_t	     set;
+	sigset_t	     old, new;
 	struct inode	     *inode;
 	struct ll_inode_info     *lli;
 
@@ -177,14 +177,15 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
 	vio->u.fault.ft_vma    = vma;
 	vio->u.fault.ft_vmpage = vmpage;
 
-	cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM), &set);
+	siginitsetinv(&new, sigmask(SIGKILL) | sigmask(SIGTERM));
+	sigprocmask(SIG_BLOCK, &new, &old);
 
 	inode = vvp_object_inode(io->ci_obj);
 	lli = ll_i2info(inode);
 
 	result = cl_io_loop(env, io);
 
-	cfs_restore_sigs(&set);
+	sigprocmask(SIG_SETMASK, &old, NULL);
 
 	if (result == 0) {
 		struct inode *inode = file_inode(vma->vm_file);
@@ -328,13 +329,14 @@ static int ll_fault(struct vm_fault *vmf)
 	int count = 0;
 	bool printed = false;
 	int result;
-	sigset_t set;
+	sigset_t old, new;
 
 	/* Only SIGKILL and SIGTERM are allowed for fault/nopage/mkwrite
 	 * so that it can be killed by admin but not cause segfault by
 	 * other signals.
 	 */
-	cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM), &set);
+	siginitsetinv(&new, sigmask(SIGKILL) | sigmask(SIGTERM));
+	sigprocmask(SIG_BLOCK, &new, &old);
 
 restart:
 	result = ll_fault0(vmf->vma, vmf);
@@ -360,7 +362,7 @@ static int ll_fault(struct vm_fault *vmf)
 
 		result = VM_FAULT_LOCKED;
 	}
-	cfs_restore_sigs(&set);
+	sigprocmask(SIG_SETMASK, &old, NULL);
 	return result;
 }
 

  reply	other threads:[~2018-05-21  4:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21  4:35 [PATCH 00/30] staging: lustre: tidy up - module init and includes NeilBrown
2018-05-21  4:35 ` NeilBrown [this message]
2018-05-21  4:35 ` [PATCH 03/30] staging: lustre: move files out of lustre/lnet/libcfs/linux/ NeilBrown
2018-05-21  4:35 ` [PATCH 07/30] staging: lustre: simplify capability dropping NeilBrown
2018-05-21  4:35 ` [PATCH 01/30] staging: lustre: osc: tidy up osc_init() NeilBrown
2018-05-21  4:35 ` [PATCH 04/30] staging: lustre: rename cfs_cpt_table to cfs_cpt_tab NeilBrown
2018-05-21  4:35 ` [PATCH 13/30] staging: lustre: replace libcfs_register_ioctl with a blocking notifier_chain NeilBrown
2018-05-21 16:06   ` [lustre-devel] " Patrick Farrell
2018-05-22 21:06     ` NeilBrown
2018-05-21  4:35 ` [PATCH 06/30] staging: lustre: remove current_pid() and current_comm() NeilBrown
2018-05-21  4:35 ` [PATCH 15/30] staging: lustre: make lnet_debugfs_symlink_def local to libcfs/modules.c NeilBrown
2018-05-21  4:35 ` [PATCH 16/30] staging: lustre: move lnet_debug_log_upcall declaration to tracefile.h NeilBrown
2018-05-21  4:35 ` [PATCH 10/30] staging: lustre: discard CFS_TICK NeilBrown
2018-05-21  4:35 ` [PATCH 02/30] staging: lustre: refactor libcfs initialization NeilBrown
2018-05-21  4:35 ` [PATCH 08/30] staging: lustre: discard cfs_cap_t, use kernel_cap_t NeilBrown
2018-05-21  4:35 ` [PATCH 05/30] staging: lustre: remove conditional compilation from libcfs_cpu.c NeilBrown
2018-05-21  4:35 ` [PATCH 14/30] staging: lustre: clean up __LIBCFS_H macro NeilBrown
2018-05-21  4:35 ` [PATCH 09/30] staging: lustre: discard LOWEST_BIT_SET() NeilBrown
2018-05-21  4:35 ` [PATCH 11/30] staging: lustre: move LERRCHKSUM() to libcfs_debug.h NeilBrown
2018-05-21  4:35 ` [PATCH 21/30] staging: lustre: don't include libcfs.h in lnet/lib-lnet.h NeilBrown
2018-05-21  4:35 ` [PATCH 19/30] staging: lustre: discard libcfs_prim.h NeilBrown
2018-05-21  4:35 ` [PATCH 27/30] staging: lustre: remove libcfs_all.h from fid, fld, obdclass NeilBrown
2018-05-21  4:35 ` [PATCH 18/30] staging: lustre: replace memory_presure funcitons by standard interfaces NeilBrown
2018-05-21  4:35 ` [PATCH 28/30] staging: lustre: remove remaining libcfs_all.h includes from lustre/lustre NeilBrown
2018-05-21  4:35 ` [PATCH 29/30] staging: lustre: move all libcfs_all includes except in lustre/lnet/libcfs/ NeilBrown
2018-05-21  4:35 ` [PATCH 22/30] staging: lustre: remove libcfs_all.h includes from lnet/klnd NeilBrown
2018-05-21  4:35 ` [PATCH 20/30] staging: lustre: start moving includes out of libcfs.h NeilBrown
2018-05-21  4:35 ` [PATCH 25/30] staging: lustre: remove libcfs_all.h from remaining .h files NeilBrown
2018-05-21  4:35 ` [PATCH 30/30] staging: lustre: remove libcfs_all.h NeilBrown
2018-05-21  4:35 ` [PATCH 24/30] staging: lustre: remove libcfs_all.h from lustre/include/*.h NeilBrown
2018-05-21  4:35 ` [PATCH 23/30] staging: lustre: remove libcfs_all.h from includes lustre/lnet NeilBrown
2018-05-21  4:35 ` [PATCH 17/30] staging: lustre: move RESV_PORT definitions to lnet/lib-lnet.h NeilBrown
2018-05-21  4:35 ` [PATCH 26/30] staging: lustre: remove libcfs_all from ptlrpc NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=152687731280.24196.2550193187633714376.stgit@noble \
    --to=neilb@suse.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).