Skip to content

Commit 0fe2f1e

Browse files
committed
GFS2: Size seq_file buffer more carefully
This places a limit on the buffer size for archs with larger PAGE_SIZE. Signed-off-by: Steven Whitehouse <[email protected]> Reported-by: Eric Dumazet <[email protected]>
1 parent 1bb4930 commit 0fe2f1e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/gfs2/glock.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,8 @@ static const struct seq_operations gfs2_sbstats_seq_ops = {
19771977
.show = gfs2_sbstats_seq_show,
19781978
};
19791979

1980+
#define GFS2_SEQ_GOODSIZE min(PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER, 65536UL)
1981+
19801982
static int gfs2_glocks_open(struct inode *inode, struct file *file)
19811983
{
19821984
int ret = seq_open_private(file, &gfs2_glock_seq_ops,
@@ -1985,9 +1987,9 @@ static int gfs2_glocks_open(struct inode *inode, struct file *file)
19851987
struct seq_file *seq = file->private_data;
19861988
struct gfs2_glock_iter *gi = seq->private;
19871989
gi->sdp = inode->i_private;
1988-
seq->buf = kmalloc(8*PAGE_SIZE, GFP_KERNEL | __GFP_NOWARN);
1990+
seq->buf = kmalloc(GFS2_SEQ_GOODSIZE, GFP_KERNEL | __GFP_NOWARN);
19891991
if (seq->buf)
1990-
seq->size = 8*PAGE_SIZE;
1992+
seq->size = GFS2_SEQ_GOODSIZE;
19911993
}
19921994
return ret;
19931995
}
@@ -2000,9 +2002,9 @@ static int gfs2_glstats_open(struct inode *inode, struct file *file)
20002002
struct seq_file *seq = file->private_data;
20012003
struct gfs2_glock_iter *gi = seq->private;
20022004
gi->sdp = inode->i_private;
2003-
seq->buf = kmalloc(8*PAGE_SIZE, GFP_KERNEL | __GFP_NOWARN);
2005+
seq->buf = kmalloc(GFS2_SEQ_GOODSIZE, GFP_KERNEL | __GFP_NOWARN);
20042006
if (seq->buf)
2005-
seq->size = 8*PAGE_SIZE;
2007+
seq->size = GFS2_SEQ_GOODSIZE;
20062008
}
20072009
return ret;
20082010
}

0 commit comments

Comments
 (0)