Skip to content

Commit 8769e07

Browse files
committed
Merge tag 'for-linus-v3.10-rc1-2' of git://oss.sgi.com/xfs/xfs
Pull xfs update (Digilent#2) from Ben Myers: - add CONFIG_XFS_WARN, a step between zero debugging and CONFIG_XFS_DEBUG. - fix attrmulti and attrlist to fall back to vmalloc when kmalloc fails. * tag 'for-linus-v3.10-rc1-2' of git://oss.sgi.com/xfs/xfs: xfs: fallback to vmalloc for large buffers in xfs_compat_attrlist_by_handle xfs: fallback to vmalloc for large buffers in xfs_attrlist_by_handle xfs: introduce CONFIG_XFS_WARN
2 parents 8cbc95e + 7dfbcbe commit 8769e07

15 files changed

Lines changed: 83 additions & 32 deletions

fs/xfs/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ config XFS_RT
6969

7070
If unsure, say N.
7171

72+
config XFS_WARN
73+
bool "XFS Verbose Warnings"
74+
depends on XFS_FS && !XFS_DEBUG
75+
help
76+
Say Y here to get an XFS build with many additional warnings.
77+
It converts ASSERT checks to WARN, so will log any out-of-bounds
78+
conditions that occur that would otherwise be missed. It is much
79+
lighter weight than XFS_DEBUG and does not modify algorithms and will
80+
not cause the kernel to panic on non-fatal errors.
81+
82+
However, similar to XFS_DEBUG, it is only advisable to use this if you
83+
are debugging a particular problem.
84+
7285
config XFS_DEBUG
7386
bool "XFS Debugging support"
7487
depends on XFS_FS

fs/xfs/mrlock.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
typedef struct {
2424
struct rw_semaphore mr_lock;
25-
#ifdef DEBUG
25+
#if defined(DEBUG) || defined(XFS_WARN)
2626
int mr_writer;
2727
#endif
2828
} mrlock_t;
2929

30-
#ifdef DEBUG
30+
#if defined(DEBUG) || defined(XFS_WARN)
3131
#define mrinit(mrp, name) \
3232
do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0)
3333
#else
@@ -46,7 +46,7 @@ static inline void mraccess_nested(mrlock_t *mrp, int subclass)
4646
static inline void mrupdate_nested(mrlock_t *mrp, int subclass)
4747
{
4848
down_write_nested(&mrp->mr_lock, subclass);
49-
#ifdef DEBUG
49+
#if defined(DEBUG) || defined(XFS_WARN)
5050
mrp->mr_writer = 1;
5151
#endif
5252
}
@@ -60,15 +60,15 @@ static inline int mrtryupdate(mrlock_t *mrp)
6060
{
6161
if (!down_write_trylock(&mrp->mr_lock))
6262
return 0;
63-
#ifdef DEBUG
63+
#if defined(DEBUG) || defined(XFS_WARN)
6464
mrp->mr_writer = 1;
6565
#endif
6666
return 1;
6767
}
6868

6969
static inline void mrunlock_excl(mrlock_t *mrp)
7070
{
71-
#ifdef DEBUG
71+
#if defined(DEBUG) || defined(XFS_WARN)
7272
mrp->mr_writer = 0;
7373
#endif
7474
up_write(&mrp->mr_lock);
@@ -81,7 +81,7 @@ static inline void mrunlock_shared(mrlock_t *mrp)
8181

8282
static inline void mrdemote(mrlock_t *mrp)
8383
{
84-
#ifdef DEBUG
84+
#if defined(DEBUG) || defined(XFS_WARN)
8585
mrp->mr_writer = 0;
8686
#endif
8787
downgrade_write(&mrp->mr_lock);

fs/xfs/xfs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
#define XFS_BUF_LOCK_TRACKING 1
2525
#endif
2626

27+
#ifdef CONFIG_XFS_WARN
28+
#define XFS_WARN 1
29+
#endif
30+
31+
2732
#include "xfs_linux.h"
2833

2934
#endif /* __XFS_H__ */

fs/xfs/xfs_alloc_btree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ const struct xfs_buf_ops xfs_allocbt_buf_ops = {
386386
};
387387

388388

389-
#ifdef DEBUG
389+
#if defined(DEBUG) || defined(XFS_WARN)
390390
STATIC int
391391
xfs_allocbt_keys_inorder(
392392
struct xfs_btree_cur *cur,
@@ -442,7 +442,7 @@ static const struct xfs_btree_ops xfs_allocbt_ops = {
442442
.init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
443443
.key_diff = xfs_allocbt_key_diff,
444444
.buf_ops = &xfs_allocbt_buf_ops,
445-
#ifdef DEBUG
445+
#if defined(DEBUG) || defined(XFS_WARN)
446446
.keys_inorder = xfs_allocbt_keys_inorder,
447447
.recs_inorder = xfs_allocbt_recs_inorder,
448448
#endif

fs/xfs/xfs_bmap_btree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ const struct xfs_buf_ops xfs_bmbt_buf_ops = {
813813
};
814814

815815

816-
#ifdef DEBUG
816+
#if defined(DEBUG) || defined(XFS_WARN)
817817
STATIC int
818818
xfs_bmbt_keys_inorder(
819819
struct xfs_btree_cur *cur,
@@ -853,7 +853,7 @@ static const struct xfs_btree_ops xfs_bmbt_ops = {
853853
.init_ptr_from_cur = xfs_bmbt_init_ptr_from_cur,
854854
.key_diff = xfs_bmbt_key_diff,
855855
.buf_ops = &xfs_bmbt_buf_ops,
856-
#ifdef DEBUG
856+
#if defined(DEBUG) || defined(XFS_WARN)
857857
.keys_inorder = xfs_bmbt_keys_inorder,
858858
.recs_inorder = xfs_bmbt_recs_inorder,
859859
#endif

fs/xfs/xfs_btree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct xfs_btree_ops {
215215

216216
const struct xfs_buf_ops *buf_ops;
217217

218-
#ifdef DEBUG
218+
#if defined(DEBUG) || defined(XFS_WARN)
219219
/* check that k1 is lower than k2 */
220220
int (*keys_inorder)(struct xfs_btree_cur *cur,
221221
union xfs_btree_key *k1,

fs/xfs/xfs_dir2_node.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ xfs_dir2_leafn_rebalance(
993993
xfs_dir2_leaf_t *leaf1; /* first leaf structure */
994994
xfs_dir2_leaf_t *leaf2; /* second leaf structure */
995995
int mid; /* midpoint leaf index */
996-
#ifdef DEBUG
996+
#if defined(DEBUG) || defined(XFS_WARN)
997997
int oldstale; /* old count of stale leaves */
998998
#endif
999999
int oldsum; /* old total leaf count */
@@ -1022,7 +1022,7 @@ xfs_dir2_leafn_rebalance(
10221022
ents2 = xfs_dir3_leaf_ents_p(leaf2);
10231023

10241024
oldsum = hdr1.count + hdr2.count;
1025-
#ifdef DEBUG
1025+
#if defined(DEBUG) || defined(XFS_WARN)
10261026
oldstale = hdr1.stale + hdr2.stale;
10271027
#endif
10281028
mid = oldsum >> 1;

fs/xfs/xfs_ialloc_btree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const struct xfs_buf_ops xfs_inobt_buf_ops = {
272272
.verify_write = xfs_inobt_write_verify,
273273
};
274274

275-
#ifdef DEBUG
275+
#if defined(DEBUG) || defined(XFS_WARN)
276276
STATIC int
277277
xfs_inobt_keys_inorder(
278278
struct xfs_btree_cur *cur,
@@ -310,7 +310,7 @@ static const struct xfs_btree_ops xfs_inobt_ops = {
310310
.init_ptr_from_cur = xfs_inobt_init_ptr_from_cur,
311311
.key_diff = xfs_inobt_key_diff,
312312
.buf_ops = &xfs_inobt_buf_ops,
313-
#ifdef DEBUG
313+
#if defined(DEBUG) || defined(XFS_WARN)
314314
.keys_inorder = xfs_inobt_keys_inorder,
315315
.recs_inorder = xfs_inobt_recs_inorder,
316316
#endif

fs/xfs/xfs_inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ xfs_ilock_demote(
287287
trace_xfs_ilock_demote(ip, lock_flags, _RET_IP_);
288288
}
289289

290-
#ifdef DEBUG
290+
#if defined(DEBUG) || defined(XFS_WARN)
291291
int
292292
xfs_isilocked(
293293
xfs_inode_t *ip,

fs/xfs/xfs_ioctl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,12 @@ xfs_attrlist_by_handle(
422422
if (IS_ERR(dentry))
423423
return PTR_ERR(dentry);
424424

425-
kbuf = kzalloc(al_hreq.buflen, GFP_KERNEL);
426-
if (!kbuf)
427-
goto out_dput;
425+
kbuf = kmem_zalloc(al_hreq.buflen, KM_SLEEP | KM_MAYFAIL);
426+
if (!kbuf) {
427+
kbuf = kmem_zalloc_large(al_hreq.buflen);
428+
if (!kbuf)
429+
goto out_dput;
430+
}
428431

429432
cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
430433
error = -xfs_attr_list(XFS_I(dentry->d_inode), kbuf, al_hreq.buflen,
@@ -436,7 +439,10 @@ xfs_attrlist_by_handle(
436439
error = -EFAULT;
437440

438441
out_kfree:
439-
kfree(kbuf);
442+
if (is_vmalloc_addr(kbuf))
443+
kmem_free_large(kbuf);
444+
else
445+
kmem_free(kbuf);
440446
out_dput:
441447
dput(dentry);
442448
return error;

0 commit comments

Comments
 (0)