mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-01 04:36:43 +07:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
220 lines
5.4 KiB
C
220 lines
5.4 KiB
C
/* AFS Volume Location Service client
|
|
*
|
|
* Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#include <linux/gfp.h>
|
|
#include <linux/init.h>
|
|
#include <linux/sched.h>
|
|
#include "internal.h"
|
|
|
|
/*
|
|
* map volume locator abort codes to error codes
|
|
*/
|
|
static int afs_vl_abort_to_error(u32 abort_code)
|
|
{
|
|
_enter("%u", abort_code);
|
|
|
|
switch (abort_code) {
|
|
case AFSVL_IDEXIST: return -EEXIST;
|
|
case AFSVL_IO: return -EREMOTEIO;
|
|
case AFSVL_NAMEEXIST: return -EEXIST;
|
|
case AFSVL_CREATEFAIL: return -EREMOTEIO;
|
|
case AFSVL_NOENT: return -ENOMEDIUM;
|
|
case AFSVL_EMPTY: return -ENOMEDIUM;
|
|
case AFSVL_ENTDELETED: return -ENOMEDIUM;
|
|
case AFSVL_BADNAME: return -EINVAL;
|
|
case AFSVL_BADINDEX: return -EINVAL;
|
|
case AFSVL_BADVOLTYPE: return -EINVAL;
|
|
case AFSVL_BADSERVER: return -EINVAL;
|
|
case AFSVL_BADPARTITION: return -EINVAL;
|
|
case AFSVL_REPSFULL: return -EFBIG;
|
|
case AFSVL_NOREPSERVER: return -ENOENT;
|
|
case AFSVL_DUPREPSERVER: return -EEXIST;
|
|
case AFSVL_RWNOTFOUND: return -ENOENT;
|
|
case AFSVL_BADREFCOUNT: return -EINVAL;
|
|
case AFSVL_SIZEEXCEEDED: return -EINVAL;
|
|
case AFSVL_BADENTRY: return -EINVAL;
|
|
case AFSVL_BADVOLIDBUMP: return -EINVAL;
|
|
case AFSVL_IDALREADYHASHED: return -EINVAL;
|
|
case AFSVL_ENTRYLOCKED: return -EBUSY;
|
|
case AFSVL_BADVOLOPER: return -EBADRQC;
|
|
case AFSVL_BADRELLOCKTYPE: return -EINVAL;
|
|
case AFSVL_RERELEASE: return -EREMOTEIO;
|
|
case AFSVL_BADSERVERFLAG: return -EINVAL;
|
|
case AFSVL_PERM: return -EACCES;
|
|
case AFSVL_NOMEM: return -EREMOTEIO;
|
|
default:
|
|
return afs_abort_to_error(abort_code);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* deliver reply data to a VL.GetEntryByXXX call
|
|
*/
|
|
static int afs_deliver_vl_get_entry_by_xxx(struct afs_call *call,
|
|
struct sk_buff *skb, bool last)
|
|
{
|
|
struct afs_cache_vlocation *entry;
|
|
__be32 *bp;
|
|
u32 tmp;
|
|
int loop;
|
|
|
|
_enter(",,%u", last);
|
|
|
|
afs_transfer_reply(call, skb);
|
|
if (!last)
|
|
return 0;
|
|
|
|
if (call->reply_size != call->reply_max)
|
|
return -EBADMSG;
|
|
|
|
/* unmarshall the reply once we've received all of it */
|
|
entry = call->reply;
|
|
bp = call->buffer;
|
|
|
|
for (loop = 0; loop < 64; loop++)
|
|
entry->name[loop] = ntohl(*bp++);
|
|
entry->name[loop] = 0;
|
|
bp++; /* final NUL */
|
|
|
|
bp++; /* type */
|
|
entry->nservers = ntohl(*bp++);
|
|
|
|
for (loop = 0; loop < 8; loop++)
|
|
entry->servers[loop].s_addr = *bp++;
|
|
|
|
bp += 8; /* partition IDs */
|
|
|
|
for (loop = 0; loop < 8; loop++) {
|
|
tmp = ntohl(*bp++);
|
|
entry->srvtmask[loop] = 0;
|
|
if (tmp & AFS_VLSF_RWVOL)
|
|
entry->srvtmask[loop] |= AFS_VOL_VTM_RW;
|
|
if (tmp & AFS_VLSF_ROVOL)
|
|
entry->srvtmask[loop] |= AFS_VOL_VTM_RO;
|
|
if (tmp & AFS_VLSF_BACKVOL)
|
|
entry->srvtmask[loop] |= AFS_VOL_VTM_BAK;
|
|
}
|
|
|
|
entry->vid[0] = ntohl(*bp++);
|
|
entry->vid[1] = ntohl(*bp++);
|
|
entry->vid[2] = ntohl(*bp++);
|
|
|
|
bp++; /* clone ID */
|
|
|
|
tmp = ntohl(*bp++); /* flags */
|
|
entry->vidmask = 0;
|
|
if (tmp & AFS_VLF_RWEXISTS)
|
|
entry->vidmask |= AFS_VOL_VTM_RW;
|
|
if (tmp & AFS_VLF_ROEXISTS)
|
|
entry->vidmask |= AFS_VOL_VTM_RO;
|
|
if (tmp & AFS_VLF_BACKEXISTS)
|
|
entry->vidmask |= AFS_VOL_VTM_BAK;
|
|
if (!entry->vidmask)
|
|
return -EBADMSG;
|
|
|
|
_leave(" = 0 [done]");
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* VL.GetEntryByName operation type
|
|
*/
|
|
static const struct afs_call_type afs_RXVLGetEntryByName = {
|
|
.name = "VL.GetEntryByName",
|
|
.deliver = afs_deliver_vl_get_entry_by_xxx,
|
|
.abort_to_error = afs_vl_abort_to_error,
|
|
.destructor = afs_flat_call_destructor,
|
|
};
|
|
|
|
/*
|
|
* VL.GetEntryById operation type
|
|
*/
|
|
static const struct afs_call_type afs_RXVLGetEntryById = {
|
|
.name = "VL.GetEntryById",
|
|
.deliver = afs_deliver_vl_get_entry_by_xxx,
|
|
.abort_to_error = afs_vl_abort_to_error,
|
|
.destructor = afs_flat_call_destructor,
|
|
};
|
|
|
|
/*
|
|
* dispatch a get volume entry by name operation
|
|
*/
|
|
int afs_vl_get_entry_by_name(struct in_addr *addr,
|
|
struct key *key,
|
|
const char *volname,
|
|
struct afs_cache_vlocation *entry,
|
|
const struct afs_wait_mode *wait_mode)
|
|
{
|
|
struct afs_call *call;
|
|
size_t volnamesz, reqsz, padsz;
|
|
__be32 *bp;
|
|
|
|
_enter("");
|
|
|
|
volnamesz = strlen(volname);
|
|
padsz = (4 - (volnamesz & 3)) & 3;
|
|
reqsz = 8 + volnamesz + padsz;
|
|
|
|
call = afs_alloc_flat_call(&afs_RXVLGetEntryByName, reqsz, 384);
|
|
if (!call)
|
|
return -ENOMEM;
|
|
|
|
call->key = key;
|
|
call->reply = entry;
|
|
call->service_id = VL_SERVICE;
|
|
call->port = htons(AFS_VL_PORT);
|
|
|
|
/* marshall the parameters */
|
|
bp = call->request;
|
|
*bp++ = htonl(VLGETENTRYBYNAME);
|
|
*bp++ = htonl(volnamesz);
|
|
memcpy(bp, volname, volnamesz);
|
|
if (padsz > 0)
|
|
memset((void *) bp + volnamesz, 0, padsz);
|
|
|
|
/* initiate the call */
|
|
return afs_make_call(addr, call, GFP_KERNEL, wait_mode);
|
|
}
|
|
|
|
/*
|
|
* dispatch a get volume entry by ID operation
|
|
*/
|
|
int afs_vl_get_entry_by_id(struct in_addr *addr,
|
|
struct key *key,
|
|
afs_volid_t volid,
|
|
afs_voltype_t voltype,
|
|
struct afs_cache_vlocation *entry,
|
|
const struct afs_wait_mode *wait_mode)
|
|
{
|
|
struct afs_call *call;
|
|
__be32 *bp;
|
|
|
|
_enter("");
|
|
|
|
call = afs_alloc_flat_call(&afs_RXVLGetEntryById, 12, 384);
|
|
if (!call)
|
|
return -ENOMEM;
|
|
|
|
call->key = key;
|
|
call->reply = entry;
|
|
call->service_id = VL_SERVICE;
|
|
call->port = htons(AFS_VL_PORT);
|
|
|
|
/* marshall the parameters */
|
|
bp = call->request;
|
|
*bp++ = htonl(VLGETENTRYBYID);
|
|
*bp++ = htonl(volid);
|
|
*bp = htonl(voltype);
|
|
|
|
/* initiate the call */
|
|
return afs_make_call(addr, call, GFP_KERNEL, wait_mode);
|
|
}
|