aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-02-01Merge tag 'staging-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/stagingLinus Torvalds84-2121/+949
Pull staging/IIO updates from Greg KH: "Here is the big Staging and IIO driver patches for 4.16-rc1. There is the normal amount of new IIO drivers added, like all releases. The networking IPX and the ncpfs filesystem are moved into the staging tree, as they are on their way out of the kernel due to lack of use anymore. The visorbus subsystem finall has started moving out of the staging tree to the "real" part of the kernel, and the most and fsl-mc codebases are almost ready to move out, that will probably happen for 4.17-rc1 if all goes well. Other than that, there is a bunch of license header cleanups in the tree, along with the normal amount of coding style churn that we all know and love for this codebase. I also got frustrated at the Meltdown/Spectre mess and took it out on the dgnc tty driver, deleting huge chunks of it that were never even being used. Full details of everything is in the shortlog. All of these patches have been in linux-next for a while with no reported issues" * tag 'staging-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (627 commits) staging: rtlwifi: remove redundant initialization of 'cfg_cmd' staging: rtl8723bs: remove a couple of redundant initializations staging: comedi: reformat lines to 80 chars or less staging: lustre: separate a connection destroy from free struct kib_conn Staging: rtl8723bs: Use !x instead of NULL comparison Staging: rtl8723bs: Remove dead code Staging: rtl8723bs: Change names to conform to the kernel code staging: ccree: Fix missing blank line after declaration staging: rtl8188eu: remove redundant initialization of 'pwrcfgcmd' staging: rtlwifi: remove unused RTLHALMAC_ST and RTLPHYDM_ST staging: fbtft: remove unused FB_TFT_SSD1325 kconfig staging: comedi: dt2811: remove redundant initialization of 'ns' staging: wilc1000: fix alignments to match open parenthesis staging: wilc1000: removed unnecessary defined enums typedef staging: wilc1000: remove unnecessary use of parentheses staging: rtl8192u: remove redundant initialization of 'timeout' staging: sm750fb: fix CamelCase for dispSet var staging: lustre: lnet/selftest: fix compile error on UP build staging: rtl8723bs: hal_com_phycfg: Remove unneeded semicolons staging: rts5208: Fix "seg_no" calculation in reset_ms_card() ...
2018-01-31Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6Linus Torvalds1-0/+1
Pull crypto updates from Herbert Xu: "API: - Enforce the setting of keys for keyed aead/hash/skcipher algorithms. - Add multibuf speed tests in tcrypt. Algorithms: - Improve performance of sha3-generic. - Add native sha512 support on arm64. - Add v8.2 Crypto Extentions version of sha3/sm3 on arm64. - Avoid hmac nesting by requiring underlying algorithm to be unkeyed. - Add cryptd_max_cpu_qlen module parameter to cryptd. Drivers: - Add support for EIP97 engine in inside-secure. - Add inline IPsec support to chelsio. - Add RevB core support to crypto4xx. - Fix AEAD ICV check in crypto4xx. - Add stm32 crypto driver. - Add support for BCM63xx platforms in bcm2835 and remove bcm63xx. - Add Derived Key Protocol (DKP) support in caam. - Add Samsung Exynos True RNG driver. - Add support for Exynos5250+ SoCs in exynos PRNG driver" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (166 commits) crypto: picoxcell - Fix error handling in spacc_probe() crypto: arm64/sha512 - fix/improve new v8.2 Crypto Extensions code crypto: arm64/sm3 - new v8.2 Crypto Extensions implementation crypto: arm64/sha3 - new v8.2 Crypto Extensions implementation crypto: testmgr - add new testcases for sha3 crypto: sha3-generic - export init/update/final routines crypto: sha3-generic - simplify code crypto: sha3-generic - rewrite KECCAK transform to help the compiler optimize crypto: sha3-generic - fixes for alignment and big endian operation crypto: aesni - handle zero length dst buffer crypto: artpec6 - remove select on non-existing CRYPTO_SHA384 hwrng: bcm2835 - Remove redundant dev_err call in bcm2835_rng_probe() crypto: stm32 - remove redundant dev_err call in stm32_cryp_probe() crypto: axis - remove unnecessary platform_get_resource() error check crypto: testmgr - test misuse of result in ahash crypto: inside-secure - make function safexcel_try_push_requests static crypto: aes-generic - fix aes-generic regression on powerpc crypto: chelsio - Fix indentation warning crypto: arm64/sha1-ce - get rid of literal pool crypto: arm64/sha2-ce - move the round constant table to .rodata section ...
2018-01-31Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfsLinus Torvalds1-9/+1
Pull misc vfs updates from Al Viro: "All kinds of misc stuff, without any unifying topic, from various people. Neil's d_anon patch, several bugfixes, introduction of kvmalloc analogue of kmemdup_user(), extending bitfield.h to deal with fixed-endians, assorted cleanups all over the place..." * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (28 commits) alpha: osf_sys.c: use timespec64 where appropriate alpha: osf_sys.c: fix put_tv32 regression jffs2: Fix use-after-free bug in jffs2_iget()'s error handling path dcache: delete unused d_hash_mask dcache: subtract d_hash_shift from 32 in advance fs/buffer.c: fold init_buffer() into init_page_buffers() fs: fold __inode_permission() into inode_permission() fs: add RWF_APPEND sctp: use vmemdup_user() rather than badly open-coding memdup_user() snd_ctl_elem_init_enum_names(): switch to vmemdup_user() replace_user_tlv(): switch to vmemdup_user() new primitive: vmemdup_user() memdup_user(): switch to GFP_USER eventfd: fold eventfd_ctx_get() into eventfd_ctx_fileget() eventfd: fold eventfd_ctx_read() into eventfd_read() eventfd: convert to use anon_inode_getfd() nfs4file: get rid of pointless include of btrfs.h uvc_v4l2: clean copyin/copyout up vme_user: don't use __copy_..._user() usx2y: don't bother with memdup_user() for 16-byte structure ...
2018-01-30Merge branch 'work.sock_recvmsg' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfsLinus Torvalds1-13/+11
Pull kern_recvmsg reduction from Al Viro: "kernel_recvmsg() is a set_fs()-using wrapper for sock_recvmsg(). In all but one case that is not needed - use of ITER_KVEC for ->msg_iter takes care of the data and does not care about set_fs(). The only exception is svc_udp_recvfrom() where we want cmsg to be store into kernel object; everything else can just use sock_recvmsg() and be done with that. A followup converting svc_udp_recvfrom() away from set_fs() (and killing kernel_recvmsg() off) is *NOT* in here - I'd like to hear what netdev folks think of the approach proposed in that followup)" * 'work.sock_recvmsg' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: tipc: switch to sock_recvmsg() smc: switch to sock_recvmsg() ipvs: switch to sock_recvmsg() mISDN: switch to sock_recvmsg() drbd: switch to sock_recvmsg() lustre lnet_sock_read(): switch to sock_recvmsg() cfs2: switch to sock_recvmsg() ncpfs: switch to sock_recvmsg() dlm: switch to sock_recvmsg() svc_recvfrom(): switch to sock_recvmsg()
2018-01-29Merge tag 'iversion-v4.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linuxLinus Torvalds1-3/+0
Pull inode->i_version rework from Jeff Layton: "This pile of patches is a rework of the inode->i_version field. We have traditionally incremented that field on every inode data or metadata change. Typically this increment needs to be logged on disk even when nothing else has changed, which is rather expensive. It turns out though that none of the consumers of that field actually require this behavior. The only real requirement for all of them is that it be different iff the inode has changed since the last time the field was checked. Given that, we can optimize away most of the i_version increments and avoid dirtying inode metadata when the only change is to the i_version and no one is querying it. Queries of the i_version field are rather rare, so we can help write performance under many common workloads. This patch series converts existing accesses of the i_version field to a new API, and then converts all of the in-kernel filesystems to use it. The last patch in the series then converts the backend implementation to a scheme that optimizes away a large portion of the metadata updates when no one is looking at it. In my own testing this series significantly helps performance with small I/O sizes. I also got this email for Christmas this year from the kernel test robot (a 244% r/w bandwidth improvement with XFS over DAX, with 4k writes): https://lkml.org/lkml/2017/12/25/8 A few of the earlier patches in this pile are also flowing to you via other trees (mm, integrity, and nfsd trees in particular)". * tag 'iversion-v4.16-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux: (22 commits) fs: handle inode->i_version more efficiently btrfs: only dirty the inode in btrfs_update_time if something was changed xfs: avoid setting XFS_ILOG_CORE if i_version doesn't need incrementing fs: only set S_VERSION when updating times if necessary IMA: switch IMA over to new i_version API xfs: convert to new i_version API ufs: use new i_version API ocfs2: convert to new i_version API nfsd: convert to new i_version API nfs: convert to new i_version API ext4: convert to new i_version API ext2: convert to new i_version API exofs: switch to new i_version API btrfs: convert to new i_version API afs: convert to new i_version API affs: convert to new i_version API fat: convert to new i_version API fs: don't take the i_lock in inode_inc_iversion fs: new API for handling inode->i_version ntfs: remove i_version handling ...
2018-01-26staging: lustre: separate a connection destroy from free struct kib_connDmitry Eremin3-7/+8
The logic of the original commit 4d99b2581eff ("staging: lustre: avoid intensive reconnecting for ko2iblnd") was assumed conditional free of struct kib_conn if the second argument free_conn in function kiblnd_destroy_conn(struct kib_conn *conn, bool free_conn) is true. But this hunk of code was dropped from original commit. As result the logic works wrong and current code use struct kib_conn after free. > drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > 3317 kiblnd_destroy_conn(conn, !peer); > ^^^^ Freed always (but should be conditionally) > 3318 > 3319 spin_lock_irqsave(lock, flags); > 3320 if (!peer) > 3321 continue; > 3322 > 3323 conn->ibc_peer = peer; > ^^^^^^^^^^^^^^ Use after free > 3324 if (peer->ibp_reconnected < KIB_RECONN_HIGH_RACE) > 3325 list_add_tail(&conn->ibc_list, > ^^^^^^^^^^^^^^ Use after free > 3326 &kiblnd_data.kib_reconn_list); > 3327 else > 3328 list_add_tail(&conn->ibc_list, > ^^^^^^^^^^^^^^ Use after free > 3329 &kiblnd_data.kib_reconn_wait); To avoid confusion this fix moved the freeing a struct kib_conn outside of the function kiblnd_destroy_conn() and free as it was intended in original commit. Cc: <stable@vger.kernel.org> # v4.6 Fixes: 4d99b2581eff ("staging: lustre: avoid intensive reconnecting for ko2iblnd") Signed-off-by: Dmitry Eremin <Dmitry.Eremin@intel.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-23staging: lustre: lnet/selftest: fix compile error on UP buildNeilBrown1-9/+8
When compiled without CONFIG_SMP, we get a compile error as ->ctb_parts is not defined. There is already a function, cfs_cpt_cpumask(), which will get the cpumask we need, and which handles the UP case by returning a NULL pointer. So use that and handle NULL. Also avoid the #ifdef by allocating a cpumask_var and copying into it, rather than sharing the mask. Reported-by: kbuild test robot <fengguang.wu@intel.com> Fixes: 6106c0f82481 ("staging: lustre: lnet: convert selftest to use workqueues") Signed-off-by: NeilBrown <neilb@suse.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22staging: lustre: libcfs: Prevent harmless read underflowDan Carpenter1-1/+1
Because this is a post-op instead of a pre-op, then it means we check if knl_buffer[-1] is a space. It doesn't really hurt anything, but it causes a static checker warning so let's fix it. Fixes: d7e09d0397e8 ("staging: add Lustre file system client support") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22staging: lustre: lnet: remove null check before kfreeSumit Pundir1-2/+1
Since kfree(NULL) is safe there is no need to place a check before it. Issue reported by checkpatch.pl Signed-off-by: Sumit Pundir <pundirsumit11@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22staging: lustre: lnet: prefer kcalloc over kzalloc with multiplySumit Pundir1-2/+2
Use kcalloc for allocating an array instead of kzalloc with multiply. kcalloc is the preferred API. Issue reported by checkpatch.pl Signed-off-by: Sumit Pundir <pundirsumit11@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22staging: lustre: Align struct member identifiersFabian Huegel1-22/+22
This patch properly left aligns all member identifiers in every struct defined in obd_class.h for better readability. Signed-off-by: Fabian Huegel <fabian_huegel@web.de> Signed-off-by: Christoph Volkert <linux@christoph-volkert.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-22staging: lustre: Fix comment styleFabian Huegel1-20/+27
Most multi-line comments started on the first line, but the preferred linux kernel style is to start multi-line comments on the second line. Some comments became less readable after the change, so we changed them to single-line comments. Signed-off-by: Fabian Huegel <fabian_huegel@web.de> Signed-off-by: Christoph Volkert <linux@christoph-volkert.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-16staging: lustre: lnet: avoid uninitialized return valueArnd Bergmann1-2/+5
gcc warns that the latest workqueue change leads to returning an uninitialized variable: drivers/staging/lustre/lnet/selftest/module.c: In function 'lnet_selftest_init': drivers/staging/lustre/lnet/selftest/module.c:98:10: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized] A failure from alloc_ordered_workqueue() tends to indicate an out-of-memory condition, so return -ENOMEM in both cases. The second error path was a preexisting bug, where we always returned zero after a kvmalloc_array() failure. Fixes: 6106c0f82481 ("staging: lustre: lnet: convert selftest to use workqueues") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-16staging: lustre: lnet: fix build warning in module.cGreg Kroah-Hartman1-1/+1
With the latest patches from Neil, we are now getting a build warning: drivers/staging/lustre/lnet/selftest/module.c: In function ‘lnet_selftest_init’: drivers/staging/lustre/lnet/selftest/module.c:98:10: warning: ‘rc’ may be used uninitialized in this function [-Wmaybe-uninitialized] return rc; ^~ So fix this up by giving a default error value to rc. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Reported-by: kbuild test robot <fengguang.wu@intel.com> Cc: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: lustre: Align backslashes in multi-line macrosFabian Huegel1-83/+83
This patch right aligns all backslashes in multi-line macros in obd_class.h for better readability. Signed-off-by: Fabian Huegel <fabian_huegel@web.de> Signed-off-by: Christoph Volkert <linux@christoph-volkert.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: lustre: Fix overlong linesFabian Huegel1-4/+10
Fixed four lines that went over the 80 character limit to reduce checkpatch warnings. Signed-off-by: Fabian Huegel <fabian_huegel@web.de> Signed-off-by: Christoph Volkert <linux@christoph-volkert.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: lustre: Add identifier names to function declarationsFabian Huegel1-10/+12
Checkpatch was complaining about missing identifier names in function declarations. So we added the missing names according to the names in the respective function implementation. *obd_import* was sometimes named *import* and sometimes *imp* (in genops.c), so to avoid confusion we just named it imp everywhere. Signed-off-by: Fabian Huegel <fabian_huegel@web.de> Signed-off-by: Christoph Volkert <linux@christoph-volkert.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: lustre: Remove DECLARE_LU_VARS macroFabian Huegel1-8/+8
This macro was only used in four places to declare two variables. It saved one line of code, but in our opinion hurt readability. So we removed the macro, substituting every occurrence with the declaration of the two variables (like the preprocessor would have done). Signed-off-by: Fabian Huegel <fabian_huegel@web.de> Signed-off-by: Christoph Volkert <linux@christoph-volkert.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: lustre: Enclose complex macros in do-while loopsFabian Huegel1-4/+12
Some complex multi-line macros were not enclosed by a do-while(0), so we fixed that. Signed-off-by: Fabian Huegel <fabian_huegel@web.de> Signed-off-by: Christoph Volkert <linux@christoph-volkert.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: lustre: libcfs: remove workitem code.NeilBrown5-582/+2
There are now no users. workqueues are doing the job that this used to do. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: lustre: lnet: convert selftest to use workqueuesNeilBrown4-82/+68
Instead of the cfs workitem library, use workqueues. As lnet wants to provide a cpu mask of allowed cpus, it needs to be a WQ_UNBOUND work queue so that tasks can run on cpus other than where they were submitted. This patch also exported apply_workqueue_attrs() which is a documented part of the workqueue API, that isn't currently exported. lustre needs it to allow workqueue thread to be limited to a subset of CPUs. Acked-by: Tejun Heo <tj@kernel.org> (for export of apply_workqueue_attrs) Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-12crypto: hash - annotate algorithms taking optional keyEric Biggers1-0/+1
We need to consistently enforce that keyed hashes cannot be used without setting the key. To do this we need a reliable way to determine whether a given hash algorithm is keyed or not. AF_ALG currently does this by checking for the presence of a ->setkey() method. However, this is actually slightly broken because the CRC-32 algorithms implement ->setkey() but can also be used without a key. (The CRC-32 "key" is not actually a cryptographic key but rather represents the initial state. If not overridden, then a default initial state is used.) Prepare to fix this by introducing a flag CRYPTO_ALG_OPTIONAL_KEY which indicates that the algorithm has a ->setkey() method, but it is not required to be called. Then set it on all the CRC-32 algorithms. The same also applies to the Adler-32 implementation in Lustre. Also, the cryptd and mcryptd templates have to pass through the flag from their underlying algorithm. Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-01-09staging: lustre: remove LIBCFS_ALLOC, LIBCFS_FREE and related macros.NeilBrown1-51/+0
LIBCFS_ALLOC LIBCFS_ALLOC_ATOMIC LIBCFS_ALLOC_POST LIBCFS_CPT_ALLOC LIBCFS_FREE are no longer used, and so are removed. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: replace LIBCFS_CPT_ALLOC()NeilBrown10-110/+88
LIBCFS_APT_ALLOC() calls kvmalloc_node() with GFP_NOFS which is not permitted. Mostly, a kmalloc_node(GFP_NOFS) is appropriate, though occasionally the allocation is large and GFP_KERNEL is acceptable, so kvmalloc_node() can be used. This patch introduces 4 alternatives to LIBCFS_CPT_ALLOC(): kmalloc_cpt() kzalloc_cpt() kvmalloc_cpt() kvzalloc_cpt(). Each takes a size, gfp flags, and cpt number. Almost every call to LIBCFS_CPT_ALLOC() passes lnet_cpt_table() as the table. This patch embeds that choice in the k*alloc_cpt() macros, and opencode kzalloc_node(..., cfs_cpt_spread_node(..)) in the one case that lnet_cpt_table() isn't used. When LIBCFS_CPT_ALLOC() is replaced, the matching LIBCFS_FREE() is also replaced, with with kfree() or kvfree() as appropriate. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: opencode LIBCFS_ALLOC_ATOMIC calls.NeilBrown1-4/+3
Just call kzalloc(GFP_ATOMIC) directly. We don't need the warning on failure. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: cfs_percpt_alloc: use kvmalloc(GFP_KERNEL)NeilBrown1-3/+3
this allocation is called from several places, but all are during initialization, so GFP_NOFS is not needed. So use kvmalloc and GFP_KERNEL. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: use kmalloc for allocating ksock_txNeilBrown2-3/+3
The size of the data structure is primarily controlled by the iovec size, which is limited to 256. Entries in this vector are 12 bytes, so the whole will always fit in a page. So it is safe to use kmalloc (kvmalloc not needed). So replace LIBCFS_ALLOC with kmalloc. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: lnet-route: use kmalloc for small allocationNeilBrown1-3/+2
This allocation is reasonably small. As the function is called "*_locked", it might not be safe to perform a GFP_KERNEL allocation, so be safe and use GFP_NOFS. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: more conversions to GFP_KERNEL allocations.NeilBrown6-48/+40
These are not called from filesystem context, so use GFP_KERNEL, not LIBCFS_ALLOC(). Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: more LIBCFS_ALLOC conversions to GFP_KERNEL allocations.NeilBrown4-30/+23
None of these need GFP_NOFS so allocate directly. Change matching LIBCFS_FREE() to kfree() or kvfree(). Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: Convert more LIBCFS_ALLOC allocation to direct GFP_KERNELNeilBrown4-38/+26
None of these need to be GFP_NOFS, so use GFP_KERNEL explicitly with kmalloc(), kvmalloc(), or kvmalloc_array(). Change matching LIBCFS_FREE() to kfree() or kvfree() Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: change some LIBCFS_ALLOC calls to k?alloc(GFP_KERNEL)NeilBrown7-39/+29
When an allocation happens from process context rather than filesystem context, it is best to use GFP_KERNEL rather than LIBCFS_ALLOC() which always uses GFP_NOFS. This include initialization during, or prior to, mount, and code run from separate worker threads. So for some of these cases, switch to kmalloc, kvmalloc, or kvmalloc_array() as appropriate. In some cases we preserve __GFP_ZERO (via kzalloc/kvzalloc), but in others it is clear that allocated memory is immediately initialized. In each case, the matching LIBCFS_FREE() is converted to kfree() or kvfree() This is just a subset of locations that need changing. As there are quite a lot, I've broken them up into several ad-hoc sets to avoid review-fatigue. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: lnet: use kmalloc/kvmalloc in router_procNeilBrown1-17/+17
The buffers allocated in router_proc are to temporarily hold strings created for procfs files. So they do not need to be zeroed and are safe to use GFP_KERNEL. So use kmalloc() directly except in two cases where it isn't trivial to confirm that the size is always small. In those cases, use kvmalloc(). Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: lnet: selftest: don't allocate small strings.NeilBrown1-151/+29
All of the "name" buffers here are at most LST_NAME_SIZE+1 bytes, so 33 bytes at most. They are only used temporarily during the life of the function that allocates them. So it is much simpler to just allocate on the stack. Worst case is lst_tet_add_ioct(), which allocates 3 for these which 99 bytes on the stack, instead of the 24 that would have been allocated for 64-bit pointers. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: lnet: switch to cpumask_var_tNeilBrown5-59/+49
So that we can use the common cpumask allocation functions, switch to cpumask_var_t. We need to be careful not to free a cpumask_var_t until the variable has been initialized, and it cannot be initialized directly. So we must be sure either that it is filled with zeros, or that zalloc_cpumask_var() has been called on it. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-09staging: lustre: replace simple cases of LIBCFS_ALLOC with kzalloc.NeilBrown22-133/+124
All usages of the form LIBCFS_ALLOC(variable, sizeof(variable)) or LIBCFS_ALLOC(variable, sizeof(variable's-type)) are changed to variable = kzalloc(sizeof(...), GFP_NOFS); Similarly, all LIBCFS_FREE(variable, sizeof(variable)) become kfree(variable); None of these need the vmalloc option, or any of the other minor benefits of LIBCFS_ALLOC(). Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08Staging: lustre: Fix prefer kcalloc over kzalloc with multiplySumit Pundir1-1/+1
Use kcalloc for allocating an array instead of kzalloc with multiply. kcalloc is the preferred API. Issue reported by checkpatch.pl Signed-off-by: Sumit Pundir <pundirsumit11@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08Staging: lustre: Fix prefer seq_puts to seq_printfSumit Pundir1-3/+3
Use seq_puts() for strings without format specifiers instead of seq_printf(). Issue reported by checkpatch.pl Signed-off-by: Sumit Pundir <pundirsumit11@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08drivers: lustre: obdclass: simplify unregister_shrinker() usageAliaksei Karaliou1-2/+1
lu_global_fini() explicitly uses knowledge about shrinker's internals to make decision about calling of unregister_shrinker(). Now this check was integrated into unregister_shrinker(), so it is safe to call it against unregistered shrinker. Signed-off-by: Aliaksei Karaliou <akaraliou.dev@gmail.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: lnet: discard CFS_ALLOC_PTRNeilBrown2-8/+5
These trivial wrappers hurt readability and as they use kvmalloc, they are overly generic. So discard them and use kmalloc/kfree as is normal in Linux. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: lnet-lib: opencode some alloc/free functions.NeilBrown8-89/+28
These functions just call LIBCFS_ALLOC() which in-turn calls kvmalloc(). In none of these cases is the 'vmalloc' option needed. LIBCFS_ALLOC also produces a warning if NULL is returned, but that can be provided with CONFIG_SLAB_DEBUG. LIBCFS_ALLOC zeros the memory, so we need to use __GFP_ZERO too. So with one exception where the alloc function is not trivial, open-code the alloc and free functions using kmalloc and kfree. Note that the 'size' used in lnet_md_alloc() is limited and less than a page because LNET_MAX_IOV is 256, so kvmalloc is not needed. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: libcfs: remove prngNeilBrown3-148/+1
The cfs prng is no longer used, so discard it. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: replace cfs_get_random_bytes calls with get_random_byte()NeilBrown3-3/+3
The cfs_get_random_bytes() interface adds nothing of value to get_random_byte() (which it uses internally). So just use the standard interface. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: replace cfs_srand() calls with add_device_randomness().NeilBrown3-26/+13
The only places that cfs_srand is called, the random bits are mixed with bits from get_random_bytes(). So it is equally effective to add entropy to either pool. So we can replace calls to cfs_srand() with calls that add the entropy with add_device_randomness(). That function adds time-based entropy, so we can discard the ktime_get_ts64 calls. One location in lustre_handles.c only adds timebased entropy. This cannot improve the entropy provided by get_random_bytes(), so just discard that call. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: replace cfs_rand() with prandom_u32_max()NeilBrown4-23/+25
All occurrences of cfs_rand() % X are replaced with prandom_u32_max(X) cfs_rand() is a simple Linear Congruential PRNG. prandom_u32_max() is at least as random, is seeded with more randomness, and uses cpu-local state to avoid cross-cpu issues. This is the first step is discarding the libcfs prng with the standard linux prng. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: libcfs: remove wi_data from cfs_workitemNeilBrown4-14/+11
In every case, the value passed via wi_data can be determined from the cfs_workitem pointer using container_of(). So use container_of(), and discard wi_data. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: libcfs: use a workqueue for rehash work.NeilBrown4-75/+31
lustre has a work-item queuing scheme that provides the same functionality as linux work_queues. To make the code easier for linux devs to follow, change to use work_queues. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: obd_mount: fix possible race with module unload.NeilBrown3-17/+24
lustre_fill_super() calls client_fill_super() without holding a reference to the module containing client_fill_super. If that module is unloaded at a bad time, this can crash. To be able to get a reference to the module using try_get_module(), we need a pointer to the module. So replace lustre_register_client_fill_super() and lustre_register_kill_super_cb() with a single lustre_register_super_ops() which also passed a module pointer. Then use a spinlock to ensure the module pointer isn't removed while try_module_get() is running, and use try_module_get() to ensure we have a reference before calling client_fill_super(). Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: obdclass: remove vfsmount option from client_fill_superNeilBrown4-12/+8
This arg is always NULL and is never used. So discard it from this and related functions. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-08staging: lustre: obdclass: remove pointless struct lustre_mount_data2NeilBrown1-15/+4
This is used to pass a void* and NULL to lustre_fill_super(). It is easier just to pass the void*. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>