Skip to content

Commit 842d223

Browse files
committed
Merge branch 'akpm' (fixes from Andrew)
Merge misc fixes from Andrew Morton: - A bunch of fixes - Finish off the idr API conversions before someone starts to use the old interfaces again. * emailed patches from Andrew Morton <akpm@linux-foundation.org>: idr: idr_alloc() shouldn't trigger lowmem warning when preloaded UAPI: fix endianness conditionals in M32R's asm/stat.h UAPI: fix endianness conditionals in linux/raid/md_p.h UAPI: fix endianness conditionals in linux/acct.h UAPI: fix endianness conditionals in linux/aio_abi.h decompressors: fix typo "POWERPC" mm/fremap.c: fix oops on error path idr: deprecate idr_pre_get() and idr_get_new[_above]() tidspbridge: convert to idr_alloc() zcache: convert to idr_alloc() mlx4: remove leftover idr_pre_get() call workqueue: convert to idr_alloc() nfsd: convert to idr_alloc() nfsd: remove unused get_new_stid() kernel/signal.c: use __ARCH_HAS_SA_RESTORER instead of SA_RESTORER signal: always clear sa_restorer on execve mm: remove_memory(): fix end_pfn setting include/linux/res_counter.h needs errno.h
2 parents ad8395e + 59bfbcf commit 842d223

16 files changed

Lines changed: 144 additions & 174 deletions

File tree

‎arch/m32r/include/uapi/asm/stat.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ struct stat64 {
6363
long long st_size;
6464
unsigned long st_blksize;
6565

66-
#if defined(__BIG_ENDIAN)
66+
#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
6767
unsigned long __pad4; /* future possible st_blocks high bits */
6868
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
69-
#elif defined(__LITTLE_ENDIAN)
69+
#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
7070
unsigned long st_blocks; /* Number 512-byte blocks allocated. */
7171
unsigned long __pad4; /* future possible st_blocks high bits */
7272
#else

‎drivers/infiniband/hw/mlx4/cm.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ void mlx4_ib_cm_paravirt_init(struct mlx4_ib_dev *dev)
362362
INIT_LIST_HEAD(&dev->sriov.cm_list);
363363
dev->sriov.sl_id_map = RB_ROOT;
364364
idr_init(&dev->sriov.pv_id_table);
365-
idr_pre_get(&dev->sriov.pv_id_table, GFP_KERNEL);
366365
}
367366

368367
/* slave = -1 ==> all slaves */

‎drivers/staging/tidspbridge/rmgr/drv.c‎

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -76,37 +76,28 @@ int drv_insert_node_res_element(void *hnode, void *node_resource,
7676
struct node_res_object **node_res_obj =
7777
(struct node_res_object **)node_resource;
7878
struct process_context *ctxt = (struct process_context *)process_ctxt;
79-
int status = 0;
8079
int retval;
8180

8281
*node_res_obj = kzalloc(sizeof(struct node_res_object), GFP_KERNEL);
83-
if (!*node_res_obj) {
84-
status = -ENOMEM;
85-
goto func_end;
86-
}
82+
if (!*node_res_obj)
83+
return -ENOMEM;
8784

8885
(*node_res_obj)->node = hnode;
89-
retval = idr_get_new(ctxt->node_id, *node_res_obj,
90-
&(*node_res_obj)->id);
91-
if (retval == -EAGAIN) {
92-
if (!idr_pre_get(ctxt->node_id, GFP_KERNEL)) {
93-
pr_err("%s: OUT OF MEMORY\n", __func__);
94-
status = -ENOMEM;
95-
goto func_end;
96-
}
97-
98-
retval = idr_get_new(ctxt->node_id, *node_res_obj,
99-
&(*node_res_obj)->id);
86+
retval = idr_alloc(ctxt->node_id, *node_res_obj, 0, 0, GFP_KERNEL);
87+
if (retval >= 0) {
88+
(*node_res_obj)->id = retval;
89+
return 0;
10090
}
101-
if (retval) {
91+
92+
kfree(*node_res_obj);
93+
94+
if (retval == -ENOSPC) {
10295
pr_err("%s: FAILED, IDR is FULL\n", __func__);
103-
status = -EFAULT;
96+
return -EFAULT;
97+
} else {
98+
pr_err("%s: OUT OF MEMORY\n", __func__);
99+
return -ENOMEM;
104100
}
105-
func_end:
106-
if (status)
107-
kfree(*node_res_obj);
108-
109-
return status;
110101
}
111102

112103
/* Release all Node resources and its context
@@ -201,35 +192,26 @@ int drv_proc_insert_strm_res_element(void *stream_obj,
201192
struct strm_res_object **pstrm_res =
202193
(struct strm_res_object **)strm_res;
203194
struct process_context *ctxt = (struct process_context *)process_ctxt;
204-
int status = 0;
205195
int retval;
206196

207197
*pstrm_res = kzalloc(sizeof(struct strm_res_object), GFP_KERNEL);
208-
if (*pstrm_res == NULL) {
209-
status = -EFAULT;
210-
goto func_end;
211-
}
198+
if (*pstrm_res == NULL)
199+
return -EFAULT;
212200

213201
(*pstrm_res)->stream = stream_obj;
214-
retval = idr_get_new(ctxt->stream_id, *pstrm_res,
215-
&(*pstrm_res)->id);
216-
if (retval == -EAGAIN) {
217-
if (!idr_pre_get(ctxt->stream_id, GFP_KERNEL)) {
218-
pr_err("%s: OUT OF MEMORY\n", __func__);
219-
status = -ENOMEM;
220-
goto func_end;
221-
}
222-
223-
retval = idr_get_new(ctxt->stream_id, *pstrm_res,
224-
&(*pstrm_res)->id);
202+
retval = idr_alloc(ctxt->stream_id, *pstrm_res, 0, 0, GFP_KERNEL);
203+
if (retval >= 0) {
204+
(*pstrm_res)->id = retval;
205+
return 0;
225206
}
226-
if (retval) {
207+
208+
if (retval == -ENOSPC) {
227209
pr_err("%s: FAILED, IDR is FULL\n", __func__);
228-
status = -EPERM;
210+
return -EPERM;
211+
} else {
212+
pr_err("%s: OUT OF MEMORY\n", __func__);
213+
return -ENOMEM;
229214
}
230-
231-
func_end:
232-
return status;
233215
}
234216

235217
static int drv_proc_free_strm_res(int id, void *p, void *process_ctxt)

‎drivers/staging/zcache/ramster/tcp.c‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -300,27 +300,22 @@ static u8 r2net_num_from_nn(struct r2net_node *nn)
300300

301301
static int r2net_prep_nsw(struct r2net_node *nn, struct r2net_status_wait *nsw)
302302
{
303-
int ret = 0;
303+
int ret;
304304

305-
do {
306-
if (!idr_pre_get(&nn->nn_status_idr, GFP_ATOMIC)) {
307-
ret = -EAGAIN;
308-
break;
309-
}
310-
spin_lock(&nn->nn_lock);
311-
ret = idr_get_new(&nn->nn_status_idr, nsw, &nsw->ns_id);
312-
if (ret == 0)
313-
list_add_tail(&nsw->ns_node_item,
314-
&nn->nn_status_list);
315-
spin_unlock(&nn->nn_lock);
316-
} while (ret == -EAGAIN);
305+
spin_lock(&nn->nn_lock);
306+
ret = idr_alloc(&nn->nn_status_idr, nsw, 0, 0, GFP_ATOMIC);
307+
if (ret >= 0) {
308+
nsw->ns_id = ret;
309+
list_add_tail(&nsw->ns_node_item, &nn->nn_status_list);
310+
}
311+
spin_unlock(&nn->nn_lock);
317312

318-
if (ret == 0) {
313+
if (ret >= 0) {
319314
init_waitqueue_head(&nsw->ns_wq);
320315
nsw->ns_sys_status = R2NET_ERR_NONE;
321316
nsw->ns_status = 0;
317+
return 0;
322318
}
323-
324319
return ret;
325320
}
326321

‎fs/nfsd/nfs4state.c‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -230,37 +230,6 @@ static void nfs4_file_put_access(struct nfs4_file *fp, int oflag)
230230
__nfs4_file_put_access(fp, oflag);
231231
}
232232

233-
static inline int get_new_stid(struct nfs4_stid *stid)
234-
{
235-
static int min_stateid = 0;
236-
struct idr *stateids = &stid->sc_client->cl_stateids;
237-
int new_stid;
238-
int error;
239-
240-
error = idr_get_new_above(stateids, stid, min_stateid, &new_stid);
241-
/*
242-
* Note: the necessary preallocation was done in
243-
* nfs4_alloc_stateid(). The idr code caps the number of
244-
* preallocations that can exist at a time, but the state lock
245-
* prevents anyone from using ours before we get here:
246-
*/
247-
WARN_ON_ONCE(error);
248-
/*
249-
* It shouldn't be a problem to reuse an opaque stateid value.
250-
* I don't think it is for 4.1. But with 4.0 I worry that, for
251-
* example, a stray write retransmission could be accepted by
252-
* the server when it should have been rejected. Therefore,
253-
* adopt a trick from the sctp code to attempt to maximize the
254-
* amount of time until an id is reused, by ensuring they always
255-
* "increase" (mod INT_MAX):
256-
*/
257-
258-
min_stateid = new_stid+1;
259-
if (min_stateid == INT_MAX)
260-
min_stateid = 0;
261-
return new_stid;
262-
}
263-
264233
static struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct
265234
kmem_cache *slab)
266235
{
@@ -273,9 +242,8 @@ kmem_cache *slab)
273242
if (!stid)
274243
return NULL;
275244

276-
if (!idr_pre_get(stateids, GFP_KERNEL))
277-
goto out_free;
278-
if (idr_get_new_above(stateids, stid, min_stateid, &new_id))
245+
new_id = idr_alloc(stateids, stid, min_stateid, 0, GFP_KERNEL);
246+
if (new_id < 0)
279247
goto out_free;
280248
stid->sc_client = cl;
281249
stid->sc_type = 0;

‎include/linux/idr.h‎

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ struct idr {
7373
*/
7474

7575
void *idr_find_slowpath(struct idr *idp, int id);
76-
int idr_pre_get(struct idr *idp, gfp_t gfp_mask);
77-
int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
7876
void idr_preload(gfp_t gfp_mask);
7977
int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask);
8078
int idr_for_each(struct idr *idp,
@@ -119,19 +117,6 @@ static inline void *idr_find(struct idr *idr, int id)
119117
return idr_find_slowpath(idr, id);
120118
}
121119

122-
/**
123-
* idr_get_new - allocate new idr entry
124-
* @idp: idr handle
125-
* @ptr: pointer you want associated with the id
126-
* @id: pointer to the allocated handle
127-
*
128-
* Simple wrapper around idr_get_new_above() w/ @starting_id of zero.
129-
*/
130-
static inline int idr_get_new(struct idr *idp, void *ptr, int *id)
131-
{
132-
return idr_get_new_above(idp, ptr, 0, id);
133-
}
134-
135120
/**
136121
* idr_for_each_entry - iterate over an idr's elements of a given type
137122
* @idp: idr handle
@@ -143,7 +128,56 @@ static inline int idr_get_new(struct idr *idp, void *ptr, int *id)
143128
entry != NULL; \
144129
++id, entry = (typeof(entry))idr_get_next((idp), &(id)))
145130

146-
void __idr_remove_all(struct idr *idp); /* don't use */
131+
/*
132+
* Don't use the following functions. These exist only to suppress
133+
* deprecated warnings on EXPORT_SYMBOL()s.
134+
*/
135+
int __idr_pre_get(struct idr *idp, gfp_t gfp_mask);
136+
int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
137+
void __idr_remove_all(struct idr *idp);
138+
139+
/**
140+
* idr_pre_get - reserve resources for idr allocation
141+
* @idp: idr handle
142+
* @gfp_mask: memory allocation flags
143+
*
144+
* Part of old alloc interface. This is going away. Use
145+
* idr_preload[_end]() and idr_alloc() instead.
146+
*/
147+
static inline int __deprecated idr_pre_get(struct idr *idp, gfp_t gfp_mask)
148+
{
149+
return __idr_pre_get(idp, gfp_mask);
150+
}
151+
152+
/**
153+
* idr_get_new_above - allocate new idr entry above or equal to a start id
154+
* @idp: idr handle
155+
* @ptr: pointer you want associated with the id
156+
* @starting_id: id to start search at
157+
* @id: pointer to the allocated handle
158+
*
159+
* Part of old alloc interface. This is going away. Use
160+
* idr_preload[_end]() and idr_alloc() instead.
161+
*/
162+
static inline int __deprecated idr_get_new_above(struct idr *idp, void *ptr,
163+
int starting_id, int *id)
164+
{
165+
return __idr_get_new_above(idp, ptr, starting_id, id);
166+
}
167+
168+
/**
169+
* idr_get_new - allocate new idr entry
170+
* @idp: idr handle
171+
* @ptr: pointer you want associated with the id
172+
* @id: pointer to the allocated handle
173+
*
174+
* Part of old alloc interface. This is going away. Use
175+
* idr_preload[_end]() and idr_alloc() instead.
176+
*/
177+
static inline int __deprecated idr_get_new(struct idr *idp, void *ptr, int *id)
178+
{
179+
return __idr_get_new_above(idp, ptr, 0, id);
180+
}
147181

148182
/**
149183
* idr_remove_all - remove all ids from the given idr tree

‎include/linux/res_counter.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include <linux/cgroup.h>
17+
#include <linux/errno.h>
1718

1819
/*
1920
* The core object. the cgroup that wishes to account for some

‎include/uapi/linux/acct.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ struct acct_v3
107107
#define ACORE 0x08 /* ... dumped core */
108108
#define AXSIG 0x10 /* ... was killed by a signal */
109109

110-
#ifdef __BIG_ENDIAN
110+
#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
111111
#define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
112-
#else
112+
#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
113113
#define ACCT_BYTEORDER 0x00 /* accounting file is little endian */
114+
#else
115+
#error unspecified endianness
114116
#endif
115117

116118
#ifndef __KERNEL__

‎include/uapi/linux/aio_abi.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ struct io_event {
6262
__s64 res2; /* secondary result */
6363
};
6464

65-
#if defined(__LITTLE_ENDIAN)
65+
#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
6666
#define PADDED(x,y) x, y
67-
#elif defined(__BIG_ENDIAN)
67+
#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
6868
#define PADDED(x,y) y, x
6969
#else
7070
#error edit for your odd byteorder.

‎include/uapi/linux/raid/md_p.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,18 @@ typedef struct mdp_superblock_s {
145145
__u32 failed_disks; /* 4 Number of failed disks */
146146
__u32 spare_disks; /* 5 Number of spare disks */
147147
__u32 sb_csum; /* 6 checksum of the whole superblock */
148-
#ifdef __BIG_ENDIAN
148+
#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
149149
__u32 events_hi; /* 7 high-order of superblock update count */
150150
__u32 events_lo; /* 8 low-order of superblock update count */
151151
__u32 cp_events_hi; /* 9 high-order of checkpoint update count */
152152
__u32 cp_events_lo; /* 10 low-order of checkpoint update count */
153-
#else
153+
#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
154154
__u32 events_lo; /* 7 low-order of superblock update count */
155155
__u32 events_hi; /* 8 high-order of superblock update count */
156156
__u32 cp_events_lo; /* 9 low-order of checkpoint update count */
157157
__u32 cp_events_hi; /* 10 high-order of checkpoint update count */
158+
#else
159+
#error unspecified endianness
158160
#endif
159161
__u32 recovery_cp; /* 11 recovery checkpoint sector count */
160162
/* There are only valid for minor_version > 90 */

0 commit comments

Comments
 (0)