Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
powerpc-utils.20340
0001-drmgr-don-t-open-sysfs-file-for-each-comma...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-drmgr-don-t-open-sysfs-file-for-each-command.patch of Package powerpc-utils.20340
From 8b03106e699de1f19b8842ebbb5a91b9a6e5fa6d Mon Sep 17 00:00:00 2001 From: Laurent Dufour <ldufour@linux.ibm.com> Date: Tue, 24 Nov 2020 19:28:48 +0100 Subject: [PATCH 1/4] drmgr: don't open sysfs file for each command The new do_kernel_dlpar_common() API will be used in later commit to remove by DRC Index LMB per LMB. This will avoiding opennig and closing the fd each time. The fd closing will now be done at the process exit time. In addition add an optinal parameter to silently ignore some error. Also, change the log level of the "success" message to debug to match the previous one saying "Trying.." Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com> --- src/drmgr/common.c | 30 +++++++++++++++++------------- src/drmgr/dr.h | 6 +++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/drmgr/common.c b/src/drmgr/common.c index 5e8135bcf77e..341777250feb 100644 --- a/src/drmgr/common.c +++ b/src/drmgr/common.c @@ -1462,39 +1462,43 @@ int kernel_dlpar_exists(void) } /** - * do_kernel_dlpar + * do_kernel_dlpar_common * @brief Use the in-kernel dlpar capabilities to perform the requested * dlpar operation. * * @param cmd command string to write to sysfs + * @silent_error if not 0, error is not reported, it's up to the caller * @returns 0 on success, !0 otherwise */ -int do_kernel_dlpar(const char *cmd, int cmdlen) +int do_kernel_dlpar_common(const char *cmd, int cmdlen, int silent_error) { - int fd, rc; - int my_errno; + static int fd = -1; + int rc; say(DEBUG, "Initiating kernel DLPAR \"%s\"\n", cmd); /* write to file */ - fd = open(SYSFS_DLPAR_FILE, O_WRONLY); - if (fd <= 0) { - say(ERROR, "Could not open %s to initiate DLPAR request\n", - SYSFS_DLPAR_FILE); - return -1; + if (fd == -1) { + fd = open(SYSFS_DLPAR_FILE, O_WRONLY); + if (fd < 0) { + say(ERROR, + "Could not open %s to initiate DLPAR request\n", + SYSFS_DLPAR_FILE); + return -1; + } } rc = write(fd, cmd, cmdlen); - my_errno = errno; - close(fd); if (rc <= 0) { + if (silent_error) + return (errno == 0) ? -1 : -errno; /* write does not set errno for rc == 0 */ say(ERROR, "Failed to write to %s: %s\n", SYSFS_DLPAR_FILE, - (rc == 0) ? "wrote 0 bytes" : strerror(my_errno)); + (rc == 0) ? "wrote 0 bytes" : strerror(errno)); return -1; } - say(INFO, "Success\n"); + say(DEBUG, "Success\n"); return 0; } diff --git a/src/drmgr/dr.h b/src/drmgr/dr.h index f171bfea73c3..ffbcfdb15cc0 100644 --- a/src/drmgr/dr.h +++ b/src/drmgr/dr.h @@ -172,5 +172,9 @@ enum drc_type to_drc_type(const char *); int handle_prrn(void); int kernel_dlpar_exists(void); -int do_kernel_dlpar(const char *, int); +int do_kernel_dlpar_common(const char *, int, int); +static inline int do_kernel_dlpar(const char *cmd, int len) +{ + return do_kernel_dlpar_common(cmd, len, 0); +} #endif -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor