diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2017-03-09 09:48:05 -0500 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2017-03-16 08:18:35 -0400 |
commit | 92ecd73a887c4a2b94daf5fc35179d75d1c4ef95 (patch) | |
tree | 6a8f293244df69e2a40bb25c2013b87276d5362f | |
parent | cc37a62785a584f4875788689f3fd1fa6e4eb291 (diff) |
gfs2: Deduplicate gfs2_{glocks,glstats}_open
Both functions are identical except for the seq_operations used.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r-- | fs/gfs2/glock.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index b2674dd4ce7c..b2638d8a2459 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -1920,10 +1920,10 @@ static const struct seq_operations gfs2_sbstats_seq_ops = { | |||
1920 | 1920 | ||
1921 | #define GFS2_SEQ_GOODSIZE min(PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER, 65536UL) | 1921 | #define GFS2_SEQ_GOODSIZE min(PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER, 65536UL) |
1922 | 1922 | ||
1923 | static int gfs2_glocks_open(struct inode *inode, struct file *file) | 1923 | static int __gfs2_glocks_open(struct inode *inode, struct file *file, |
1924 | const struct seq_operations *ops) | ||
1924 | { | 1925 | { |
1925 | int ret = seq_open_private(file, &gfs2_glock_seq_ops, | 1926 | int ret = seq_open_private(file, ops, sizeof(struct gfs2_glock_iter)); |
1926 | sizeof(struct gfs2_glock_iter)); | ||
1927 | if (ret == 0) { | 1927 | if (ret == 0) { |
1928 | struct seq_file *seq = file->private_data; | 1928 | struct seq_file *seq = file->private_data; |
1929 | struct gfs2_glock_iter *gi = seq->private; | 1929 | struct gfs2_glock_iter *gi = seq->private; |
@@ -1939,6 +1939,11 @@ static int gfs2_glocks_open(struct inode *inode, struct file *file) | |||
1939 | return ret; | 1939 | return ret; |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | static int gfs2_glocks_open(struct inode *inode, struct file *file) | ||
1943 | { | ||
1944 | return __gfs2_glocks_open(inode, file, &gfs2_glock_seq_ops); | ||
1945 | } | ||
1946 | |||
1942 | static int gfs2_glocks_release(struct inode *inode, struct file *file) | 1947 | static int gfs2_glocks_release(struct inode *inode, struct file *file) |
1943 | { | 1948 | { |
1944 | struct seq_file *seq = file->private_data; | 1949 | struct seq_file *seq = file->private_data; |
@@ -1951,20 +1956,7 @@ static int gfs2_glocks_release(struct inode *inode, struct file *file) | |||
1951 | 1956 | ||
1952 | static int gfs2_glstats_open(struct inode *inode, struct file *file) | 1957 | static int gfs2_glstats_open(struct inode *inode, struct file *file) |
1953 | { | 1958 | { |
1954 | int ret = seq_open_private(file, &gfs2_glstats_seq_ops, | 1959 | return __gfs2_glocks_open(inode, file, &gfs2_glstats_seq_ops); |
1955 | sizeof(struct gfs2_glock_iter)); | ||
1956 | if (ret == 0) { | ||
1957 | struct seq_file *seq = file->private_data; | ||
1958 | struct gfs2_glock_iter *gi = seq->private; | ||
1959 | gi->sdp = inode->i_private; | ||
1960 | gi->last_pos = 0; | ||
1961 | seq->buf = kmalloc(GFS2_SEQ_GOODSIZE, GFP_KERNEL | __GFP_NOWARN); | ||
1962 | if (seq->buf) | ||
1963 | seq->size = GFS2_SEQ_GOODSIZE; | ||
1964 | gi->gl = NULL; | ||
1965 | ret = rhashtable_walk_init(&gl_hash_table, &gi->hti, GFP_KERNEL); | ||
1966 | } | ||
1967 | return ret; | ||
1968 | } | 1960 | } |
1969 | 1961 | ||
1970 | static int gfs2_sbstats_open(struct inode *inode, struct file *file) | 1962 | static int gfs2_sbstats_open(struct inode *inode, struct file *file) |