[GFS2] Tidy up dir code as per Christoph Hellwig's comments
1. Comment whitespace fix 2. Removed unused header files from dir.c 3. Split the gfs2_dir_get_buffer() function into two functions Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
@@ -111,7 +111,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer,
|
|||||||
if (isdir) {
|
if (isdir) {
|
||||||
block = gfs2_alloc_meta(ip);
|
block = gfs2_alloc_meta(ip);
|
||||||
|
|
||||||
error = gfs2_dir_get_buffer(ip, block, 1, &bh);
|
error = gfs2_dir_get_new_buffer(ip, block, &bh);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_brelse;
|
goto out_brelse;
|
||||||
gfs2_buffer_copy_tail(bh,
|
gfs2_buffer_copy_tail(bh,
|
||||||
|
@@ -42,10 +42,10 @@
|
|||||||
*
|
*
|
||||||
* When the dirents are in leaves, the actual contents of the directory file are
|
* When the dirents are in leaves, the actual contents of the directory file are
|
||||||
* used as an array of 64-bit block pointers pointing to the leaf blocks. The
|
* used as an array of 64-bit block pointers pointing to the leaf blocks. The
|
||||||
* dirents are NOT in the directory file itself. There can be more than one block
|
* dirents are NOT in the directory file itself. There can be more than one
|
||||||
* pointer in the array that points to the same leaf. In fact, when a directory
|
* block pointer in the array that points to the same leaf. In fact, when a
|
||||||
* is first converted from linear to exhash, all of the pointers point to the
|
* directory is first converted from linear to exhash, all of the pointers
|
||||||
* same leaf.
|
* point to the same leaf.
|
||||||
*
|
*
|
||||||
* When a leaf is completely full, the size of the hash table can be
|
* When a leaf is completely full, the size of the hash table can be
|
||||||
* doubled unless it is already at the maximum size which is hard coded into
|
* doubled unless it is already at the maximum size which is hard coded into
|
||||||
@@ -56,13 +56,11 @@
|
|||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/completion.h>
|
|
||||||
#include <linux/buffer_head.h>
|
#include <linux/buffer_head.h>
|
||||||
#include <linux/sort.h>
|
#include <linux/sort.h>
|
||||||
#include <linux/gfs2_ondisk.h>
|
#include <linux/gfs2_ondisk.h>
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <asm/semaphore.h>
|
|
||||||
|
|
||||||
#include "gfs2.h"
|
#include "gfs2.h"
|
||||||
#include "lm_interface.h"
|
#include "lm_interface.h"
|
||||||
@@ -92,34 +90,37 @@ typedef int (*leaf_call_t) (struct gfs2_inode *dip,
|
|||||||
uint32_t index, uint32_t len, uint64_t leaf_no,
|
uint32_t index, uint32_t len, uint64_t leaf_no,
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
int gfs2_dir_get_buffer(struct gfs2_inode *ip, uint64_t block, int new,
|
|
||||||
|
int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, uint64_t block,
|
||||||
struct buffer_head **bhp)
|
struct buffer_head **bhp)
|
||||||
{
|
{
|
||||||
struct buffer_head *bh;
|
struct buffer_head *bh;
|
||||||
int error = 0;
|
|
||||||
|
|
||||||
if (new) {
|
|
||||||
bh = gfs2_meta_new(ip->i_gl, block);
|
bh = gfs2_meta_new(ip->i_gl, block);
|
||||||
gfs2_trans_add_bh(ip->i_gl, bh, 1);
|
gfs2_trans_add_bh(ip->i_gl, bh, 1);
|
||||||
gfs2_metatype_set(bh, GFS2_METATYPE_JD, GFS2_FORMAT_JD);
|
gfs2_metatype_set(bh, GFS2_METATYPE_JD, GFS2_FORMAT_JD);
|
||||||
gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header));
|
gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header));
|
||||||
} else {
|
*bhp = bh;
|
||||||
error = gfs2_meta_read(ip->i_gl, block, DIO_START | DIO_WAIT,
|
return 0;
|
||||||
&bh);
|
}
|
||||||
|
|
||||||
|
static int gfs2_dir_get_existing_buffer(struct gfs2_inode *ip, uint64_t block,
|
||||||
|
struct buffer_head **bhp)
|
||||||
|
{
|
||||||
|
struct buffer_head *bh;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = gfs2_meta_read(ip->i_gl, block, DIO_START | DIO_WAIT, &bh);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_JD)) {
|
if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_JD)) {
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*bhp = bh;
|
*bhp = bh;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
|
static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
|
||||||
unsigned int offset, unsigned int size)
|
unsigned int offset, unsigned int size)
|
||||||
|
|
||||||
@@ -205,9 +206,11 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = gfs2_dir_get_buffer(ip, dblock,
|
if (amount == sdp->sd_jbsize || new)
|
||||||
(amount == sdp->sd_jbsize) ?
|
error = gfs2_dir_get_new_buffer(ip, dblock, &bh);
|
||||||
1 : new, &bh);
|
else
|
||||||
|
error = gfs2_dir_get_existing_buffer(ip, dblock, &bh);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@@ -321,7 +324,10 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf,
|
|||||||
gfs2_meta_ra(ip->i_gl, dblock, extlen);
|
gfs2_meta_ra(ip->i_gl, dblock, extlen);
|
||||||
|
|
||||||
if (dblock) {
|
if (dblock) {
|
||||||
error = gfs2_dir_get_buffer(ip, dblock, new, &bh);
|
if (new)
|
||||||
|
error = gfs2_dir_get_new_buffer(ip, dblock, &bh);
|
||||||
|
else
|
||||||
|
error = gfs2_dir_get_existing_buffer(ip, dblock, &bh);
|
||||||
if (error)
|
if (error)
|
||||||
goto fail;
|
goto fail;
|
||||||
dblock++;
|
dblock++;
|
||||||
|
@@ -41,7 +41,7 @@ int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip);
|
|||||||
|
|
||||||
int gfs2_diradd_alloc_required(struct inode *dir,
|
int gfs2_diradd_alloc_required(struct inode *dir,
|
||||||
const struct qstr *filename);
|
const struct qstr *filename);
|
||||||
int gfs2_dir_get_buffer(struct gfs2_inode *ip, uint64_t block, int new,
|
int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, uint64_t block,
|
||||||
struct buffer_head **bhp);
|
struct buffer_head **bhp);
|
||||||
|
|
||||||
static inline uint32_t gfs2_disk_hash(const char *data, int len)
|
static inline uint32_t gfs2_disk_hash(const char *data, int len)
|
||||||
|
Reference in New Issue
Block a user