X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fkernelcomm.c;h=7afb9484a8a69855dfc9adb291d3a1d9f7a310ed;hb=8520cfb2f77b6fc89a9c0e174f783d745dbaf2e3;hp=c4948ba27e3f9dcc91b3b04a19111f706594649f;hpb=c73736545fafac4373569187e064aab9cd435320;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/kernelcomm.c b/lustre/obdclass/kernelcomm.c index c4948ba..7afb948 100644 --- a/lustre/obdclass/kernelcomm.c +++ b/lustre/obdclass/kernelcomm.c @@ -23,7 +23,7 @@ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2015, Intel Corporation. + * Copyright (c) 2015, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -36,33 +36,11 @@ #define DEBUG_SUBSYSTEM S_CLASS +#include + #include #include -/* write a userspace buffer to disk. - * NOTE: this returns 0 on success, not the number of bytes written. */ -static ssize_t -filp_user_write(struct file *filp, const void *buf, size_t count, - loff_t *offset) -{ - mm_segment_t fs; - ssize_t size = 0; - - fs = get_fs(); - set_fs(KERNEL_DS); - while ((ssize_t)count > 0) { - size = vfs_write(filp, (const void __user *)buf, count, offset); - if (size < 0) - break; - count -= size; - buf += size; - size = 0; - } - set_fs(fs); - - return size; -} - /** * libcfs_kkuc_msg_put - send an message from kernel to userspace * @param fp to send the message to @@ -72,10 +50,11 @@ filp_user_write(struct file *filp, const void *buf, size_t count, int libcfs_kkuc_msg_put(struct file *filp, void *payload) { struct kuc_hdr *kuch = (struct kuc_hdr *)payload; - int rc = -ENOSYS; + ssize_t count = kuch->kuc_msglen; loff_t offset = 0; + int rc = 0; - if (filp == NULL || IS_ERR(filp)) + if (IS_ERR_OR_NULL(filp)) return -EBADF; if (kuch->kuc_magic != KUC_MAGIC) { @@ -83,7 +62,15 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload) return -ENOSYS; } - rc = filp_user_write(filp, payload, kuch->kuc_msglen, &offset); + while (count > 0) { + rc = cfs_kernel_write(filp, payload, count, &offset); + if (rc < 0) + break; + count -= rc; + payload += rc; + rc = 0; + } + if (rc < 0) CWARN("message send failed (%d)\n", rc); else