Skip to content

Commit 1499b8a

Browse files
committed
Merge branch 'guilt/5.19-miscellaneous' into xfs-5.19-for-next
2 parents 9a5280b + 2d9ac43 commit 1499b8a

File tree

15 files changed

+247
-132
lines changed

15 files changed

+247
-132
lines changed

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,14 +1008,14 @@ xfs_rtfree_extent(
10081008
/* Find all the free records within a given range. */
10091009
int
10101010
xfs_rtalloc_query_range(
1011+
struct xfs_mount *mp,
10111012
struct xfs_trans *tp,
10121013
const struct xfs_rtalloc_rec *low_rec,
10131014
const struct xfs_rtalloc_rec *high_rec,
10141015
xfs_rtalloc_query_range_fn fn,
10151016
void *priv)
10161017
{
10171018
struct xfs_rtalloc_rec rec;
1018-
struct xfs_mount *mp = tp->t_mountp;
10191019
xfs_rtblock_t rtstart;
10201020
xfs_rtblock_t rtend;
10211021
xfs_rtblock_t high_key;
@@ -1048,7 +1048,7 @@ xfs_rtalloc_query_range(
10481048
rec.ar_startext = rtstart;
10491049
rec.ar_extcount = rtend - rtstart + 1;
10501050

1051-
error = fn(tp, &rec, priv);
1051+
error = fn(mp, tp, &rec, priv);
10521052
if (error)
10531053
break;
10541054
}
@@ -1062,17 +1062,18 @@ xfs_rtalloc_query_range(
10621062
/* Find all the free records. */
10631063
int
10641064
xfs_rtalloc_query_all(
1065+
struct xfs_mount *mp,
10651066
struct xfs_trans *tp,
10661067
xfs_rtalloc_query_range_fn fn,
10671068
void *priv)
10681069
{
10691070
struct xfs_rtalloc_rec keys[2];
10701071

10711072
keys[0].ar_startext = 0;
1072-
keys[1].ar_startext = tp->t_mountp->m_sb.sb_rextents - 1;
1073+
keys[1].ar_startext = mp->m_sb.sb_rextents - 1;
10731074
keys[0].ar_extcount = keys[1].ar_extcount = 0;
10741075

1075-
return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv);
1076+
return xfs_rtalloc_query_range(mp, tp, &keys[0], &keys[1], fn, priv);
10761077
}
10771078

10781079
/* Is the given extent all free? */

fs/xfs/libxfs/xfs_sb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,11 @@ xfs_log_sb(
911911
* reservations that have been taken out percpu counters. If we have an
912912
* unclean shutdown, this will be corrected by log recovery rebuilding
913913
* the counters from the AGF block counts.
914+
*
915+
* Do not update sb_frextents here because it is not part of the lazy
916+
* sb counters, despite having a percpu counter. It is always kept
917+
* consistent with the ondisk rtbitmap by xfs_trans_apply_sb_deltas()
918+
* and hence we don't need have to update it here.
914919
*/
915920
if (xfs_has_lazysbcount(mp)) {
916921
mp->m_sb.sb_icount = percpu_counter_sum(&mp->m_icount);

fs/xfs/scrub/rtbitmap.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ xchk_setup_rt(
4040
/* Scrub a free extent record from the realtime bitmap. */
4141
STATIC int
4242
xchk_rtbitmap_rec(
43+
struct xfs_mount *mp,
4344
struct xfs_trans *tp,
4445
const struct xfs_rtalloc_rec *rec,
4546
void *priv)
@@ -48,10 +49,10 @@ xchk_rtbitmap_rec(
4849
xfs_rtblock_t startblock;
4950
xfs_rtblock_t blockcount;
5051

51-
startblock = rec->ar_startext * tp->t_mountp->m_sb.sb_rextsize;
52-
blockcount = rec->ar_extcount * tp->t_mountp->m_sb.sb_rextsize;
52+
startblock = rec->ar_startext * mp->m_sb.sb_rextsize;
53+
blockcount = rec->ar_extcount * mp->m_sb.sb_rextsize;
5354

54-
if (!xfs_verify_rtext(sc->mp, startblock, blockcount))
55+
if (!xfs_verify_rtext(mp, startblock, blockcount))
5556
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, 0);
5657
return 0;
5758
}
@@ -114,7 +115,7 @@ xchk_rtbitmap(
114115
if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT))
115116
return error;
116117

117-
error = xfs_rtalloc_query_all(sc->tp, xchk_rtbitmap_rec, sc);
118+
error = xfs_rtalloc_query_all(sc->mp, sc->tp, xchk_rtbitmap_rec, sc);
118119
if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, 0, &error))
119120
goto out;
120121

fs/xfs/xfs_file.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,7 @@ xfs_file_buffered_write(
694694
struct kiocb *iocb,
695695
struct iov_iter *from)
696696
{
697-
struct file *file = iocb->ki_filp;
698-
struct address_space *mapping = file->f_mapping;
699-
struct inode *inode = mapping->host;
697+
struct inode *inode = iocb->ki_filp->f_mapping->host;
700698
struct xfs_inode *ip = XFS_I(inode);
701699
ssize_t ret;
702700
bool cleared_space = false;
@@ -767,9 +765,7 @@ xfs_file_write_iter(
767765
struct kiocb *iocb,
768766
struct iov_iter *from)
769767
{
770-
struct file *file = iocb->ki_filp;
771-
struct address_space *mapping = file->f_mapping;
772-
struct inode *inode = mapping->host;
768+
struct inode *inode = iocb->ki_filp->f_mapping->host;
773769
struct xfs_inode *ip = XFS_I(inode);
774770
ssize_t ret;
775771
size_t ocount = iov_iter_count(from);
@@ -1167,12 +1163,10 @@ xfs_file_open(
11671163
struct inode *inode,
11681164
struct file *file)
11691165
{
1170-
if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
1171-
return -EFBIG;
11721166
if (xfs_is_shutdown(XFS_M(inode->i_sb)))
11731167
return -EIO;
11741168
file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
1175-
return 0;
1169+
return generic_file_open(inode, file);
11761170
}
11771171

11781172
STATIC int

fs/xfs/xfs_fsmap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,11 @@ xfs_getfsmap_logdev(
450450
/* Transform a rtbitmap "record" into a fsmap */
451451
STATIC int
452452
xfs_getfsmap_rtdev_rtbitmap_helper(
453+
struct xfs_mount *mp,
453454
struct xfs_trans *tp,
454455
const struct xfs_rtalloc_rec *rec,
455456
void *priv)
456457
{
457-
struct xfs_mount *mp = tp->t_mountp;
458458
struct xfs_getfsmap_info *info = priv;
459459
struct xfs_rmap_irec irec;
460460
xfs_daddr_t rec_daddr;
@@ -535,7 +535,7 @@ xfs_getfsmap_rtdev_rtbitmap_query(
535535
do_div(alow.ar_startext, mp->m_sb.sb_rextsize);
536536
if (do_div(ahigh.ar_startext, mp->m_sb.sb_rextsize))
537537
ahigh.ar_startext++;
538-
error = xfs_rtalloc_query_range(tp, &alow, &ahigh,
538+
error = xfs_rtalloc_query_range(mp, tp, &alow, &ahigh,
539539
xfs_getfsmap_rtdev_rtbitmap_helper, info);
540540
if (error)
541541
goto err;
@@ -547,7 +547,7 @@ xfs_getfsmap_rtdev_rtbitmap_query(
547547
info->last = true;
548548
ahigh.ar_startext = min(mp->m_sb.sb_rextents, ahigh.ar_startext);
549549

550-
error = xfs_getfsmap_rtdev_rtbitmap_helper(tp, &ahigh, info);
550+
error = xfs_getfsmap_rtdev_rtbitmap_helper(mp, tp, &ahigh, info);
551551
if (error)
552552
goto err;
553553
err:

fs/xfs/xfs_fsops.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ xfs_fs_counts(
349349
cnt->freeino = percpu_counter_read_positive(&mp->m_ifree);
350350
cnt->freedata = percpu_counter_read_positive(&mp->m_fdblocks) -
351351
xfs_fdblocks_unavailable(mp);
352-
353-
spin_lock(&mp->m_sb_lock);
354-
cnt->freertx = mp->m_sb.sb_frextents;
355-
spin_unlock(&mp->m_sb_lock);
352+
cnt->freertx = percpu_counter_read_positive(&mp->m_frextents);
356353
}
357354

358355
/*

fs/xfs/xfs_icache.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,13 +1916,16 @@ xfs_inodegc_want_queue_rt_file(
19161916
struct xfs_inode *ip)
19171917
{
19181918
struct xfs_mount *mp = ip->i_mount;
1919-
uint64_t freertx;
19201919

19211920
if (!XFS_IS_REALTIME_INODE(ip))
19221921
return false;
19231922

1924-
freertx = READ_ONCE(mp->m_sb.sb_frextents);
1925-
return freertx < mp->m_low_rtexts[XFS_LOWSP_5_PCNT];
1923+
if (__percpu_counter_compare(&mp->m_frextents,
1924+
mp->m_low_rtexts[XFS_LOWSP_5_PCNT],
1925+
XFS_FDBLOCKS_BATCH) < 0)
1926+
return true;
1927+
1928+
return false;
19261929
}
19271930
#else
19281931
# define xfs_inodegc_want_queue_rt_file(ip) (false)

fs/xfs/xfs_message.c

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,32 @@ __xfs_printk(
2727
printk("%sXFS: %pV\n", level, vaf);
2828
}
2929

30-
#define define_xfs_printk_level(func, kern_level) \
31-
void func(const struct xfs_mount *mp, const char *fmt, ...) \
32-
{ \
33-
struct va_format vaf; \
34-
va_list args; \
35-
int level; \
36-
\
37-
va_start(args, fmt); \
38-
\
39-
vaf.fmt = fmt; \
40-
vaf.va = &args; \
41-
\
42-
__xfs_printk(kern_level, mp, &vaf); \
43-
va_end(args); \
44-
\
45-
if (!kstrtoint(kern_level, 0, &level) && \
46-
level <= LOGLEVEL_ERR && \
47-
xfs_error_level >= XFS_ERRLEVEL_HIGH) \
48-
xfs_stack_trace(); \
49-
} \
50-
51-
define_xfs_printk_level(xfs_emerg, KERN_EMERG);
52-
define_xfs_printk_level(xfs_alert, KERN_ALERT);
53-
define_xfs_printk_level(xfs_crit, KERN_CRIT);
54-
define_xfs_printk_level(xfs_err, KERN_ERR);
55-
define_xfs_printk_level(xfs_warn, KERN_WARNING);
56-
define_xfs_printk_level(xfs_notice, KERN_NOTICE);
57-
define_xfs_printk_level(xfs_info, KERN_INFO);
58-
#ifdef DEBUG
59-
define_xfs_printk_level(xfs_debug, KERN_DEBUG);
60-
#endif
30+
void
31+
xfs_printk_level(
32+
const char *kern_level,
33+
const struct xfs_mount *mp,
34+
const char *fmt, ...)
35+
{
36+
struct va_format vaf;
37+
va_list args;
38+
int level;
39+
40+
va_start(args, fmt);
41+
vaf.fmt = fmt;
42+
vaf.va = &args;
43+
44+
__xfs_printk(kern_level, mp, &vaf);
45+
46+
va_end(args);
47+
48+
if (!kstrtoint(kern_level, 0, &level) &&
49+
level <= LOGLEVEL_ERR &&
50+
xfs_error_level >= XFS_ERRLEVEL_HIGH)
51+
xfs_stack_trace();
52+
}
6153

6254
void
63-
xfs_alert_tag(
55+
_xfs_alert_tag(
6456
const struct xfs_mount *mp,
6557
int panic_tag,
6658
const char *fmt, ...)

fs/xfs/xfs_message.h

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,45 @@
66

77
struct xfs_mount;
88

9-
extern __printf(2, 3)
10-
void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...);
11-
extern __printf(2, 3)
12-
void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...);
139
extern __printf(3, 4)
14-
void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...);
15-
extern __printf(2, 3)
16-
void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...);
17-
extern __printf(2, 3)
18-
void xfs_err(const struct xfs_mount *mp, const char *fmt, ...);
19-
extern __printf(2, 3)
20-
void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...);
21-
extern __printf(2, 3)
22-
void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...);
23-
extern __printf(2, 3)
24-
void xfs_info(const struct xfs_mount *mp, const char *fmt, ...);
10+
void xfs_printk_level(const char *kern_level, const struct xfs_mount *mp,
11+
const char *fmt, ...);
2512

13+
#define xfs_printk_index_wrap(kern_level, mp, fmt, ...) \
14+
({ \
15+
printk_index_subsys_emit("%sXFS%s: ", kern_level, fmt); \
16+
xfs_printk_level(kern_level, mp, fmt, ##__VA_ARGS__); \
17+
})
18+
#define xfs_emerg(mp, fmt, ...) \
19+
xfs_printk_index_wrap(KERN_EMERG, mp, fmt, ##__VA_ARGS__)
20+
#define xfs_alert(mp, fmt, ...) \
21+
xfs_printk_index_wrap(KERN_ALERT, mp, fmt, ##__VA_ARGS__)
22+
#define xfs_crit(mp, fmt, ...) \
23+
xfs_printk_index_wrap(KERN_CRIT, mp, fmt, ##__VA_ARGS__)
24+
#define xfs_err(mp, fmt, ...) \
25+
xfs_printk_index_wrap(KERN_ERR, mp, fmt, ##__VA_ARGS__)
26+
#define xfs_warn(mp, fmt, ...) \
27+
xfs_printk_index_wrap(KERN_WARNING, mp, fmt, ##__VA_ARGS__)
28+
#define xfs_notice(mp, fmt, ...) \
29+
xfs_printk_index_wrap(KERN_NOTICE, mp, fmt, ##__VA_ARGS__)
30+
#define xfs_info(mp, fmt, ...) \
31+
xfs_printk_index_wrap(KERN_INFO, mp, fmt, ##__VA_ARGS__)
2632
#ifdef DEBUG
27-
extern __printf(2, 3)
28-
void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...);
33+
#define xfs_debug(mp, fmt, ...) \
34+
xfs_printk_index_wrap(KERN_DEBUG, mp, fmt, ##__VA_ARGS__)
2935
#else
30-
static inline __printf(2, 3)
31-
void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...)
32-
{
33-
}
36+
#define xfs_debug(mp, fmt, ...) do {} while (0)
3437
#endif
3538

39+
#define xfs_alert_tag(mp, tag, fmt, ...) \
40+
({ \
41+
printk_index_subsys_emit("%sXFS%s: ", KERN_ALERT, fmt); \
42+
_xfs_alert_tag(mp, tag, fmt, ##__VA_ARGS__); \
43+
})
44+
45+
extern __printf(3, 4)
46+
void _xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...);
47+
3648
#define xfs_printk_ratelimited(func, dev, fmt, ...) \
3749
do { \
3850
static DEFINE_RATELIMIT_STATE(_rs, \

0 commit comments

Comments
 (0)