提交 61a30dcb 编写于 作者: S Steven Whitehouse

[GFS2] Fix for lock recursion problem for internal files

Two internal files which are read through the gfs2_internal_read()
routine were already locked when the routine was called and this
do not need locking at the redapages level.

This patch introduces a struct file which is used as a sentinal
so that readpage will only perform locking in the case that the
struct file passed to it is _not_ equal to this sentinal.

Since the comments in the generic kernel code indicate that the
struct file will never be used for anything other than passing
straight through to readpage(), this should be ok.
Signed-off-by: NSteven Whitehouse <swhiteho@redhat.com>
上级 4dd651ad
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "quota.h" #include "quota.h"
#include "trans.h" #include "trans.h"
#include "rgrp.h" #include "rgrp.h"
#include "ops_file.h"
/** /**
* gfs2_get_block - Fills in a buffer head with details about a block * gfs2_get_block - Fills in a buffer head with details about a block
...@@ -267,10 +268,12 @@ static int gfs2_readpage(struct file *file, struct page *page) ...@@ -267,10 +268,12 @@ static int gfs2_readpage(struct file *file, struct page *page)
atomic_inc(&sdp->sd_ops_address); atomic_inc(&sdp->sd_ops_address);
gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); if (file != &gfs2_internal_file_sentinal) {
error = gfs2_glock_nq_m_atime(1, &gh); gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
if (error) error = gfs2_glock_nq_m_atime(1, &gh);
goto out_unlock; if (error)
goto out_unlock;
}
if (gfs2_is_stuffed(ip)) { if (gfs2_is_stuffed(ip)) {
if (!page->index) { if (!page->index) {
...@@ -284,8 +287,10 @@ static int gfs2_readpage(struct file *file, struct page *page) ...@@ -284,8 +287,10 @@ static int gfs2_readpage(struct file *file, struct page *page)
if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
error = -EIO; error = -EIO;
gfs2_glock_dq_m(1, &gh); if (file != &gfs2_internal_file_sentinal) {
gfs2_holder_uninit(&gh); gfs2_glock_dq_m(1, &gh);
gfs2_holder_uninit(&gh);
}
out: out:
return error; return error;
out_unlock: out_unlock:
......
...@@ -67,6 +67,16 @@ struct filldir_reg { ...@@ -67,6 +67,16 @@ struct filldir_reg {
void *fdr_opaque; void *fdr_opaque;
}; };
/*
* Most fields left uninitialised to catch anybody who tries to
* use them. f_flags set to prevent file_accessed() from touching
* any other part of this. Its use is purely as a flag so that we
* know (in readpage()) whether or not do to locking.
*/
struct file gfs2_internal_file_sentinal = {
.f_flags = O_NOATIME|O_RDONLY,
};
static int gfs2_read_actor(read_descriptor_t *desc, struct page *page, static int gfs2_read_actor(read_descriptor_t *desc, struct page *page,
unsigned long offset, unsigned long size) unsigned long offset, unsigned long size)
{ {
...@@ -95,7 +105,9 @@ int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state, ...@@ -95,7 +105,9 @@ int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state,
desc.arg.buf = buf; desc.arg.buf = buf;
desc.count = size; desc.count = size;
desc.error = 0; desc.error = 0;
do_generic_mapping_read(inode->i_mapping, ra_state, NULL, pos, &desc, gfs2_read_actor); do_generic_mapping_read(inode->i_mapping, ra_state,
&gfs2_internal_file_sentinal, pos, &desc,
gfs2_read_actor);
return desc.written ? desc.written : desc.error; return desc.written ? desc.written : desc.error;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifndef __OPS_FILE_DOT_H__ #ifndef __OPS_FILE_DOT_H__
#define __OPS_FILE_DOT_H__ #define __OPS_FILE_DOT_H__
extern struct file gfs2_internal_file_sentinal;
extern int gfs2_internal_read(struct gfs2_inode *ip, extern int gfs2_internal_read(struct gfs2_inode *ip,
struct file_ra_state *ra_state, struct file_ra_state *ra_state,
char *buf, loff_t *pos, unsigned size); char *buf, loff_t *pos, unsigned size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册