Release 4.10 fs/ocfs2/dir.c
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
* dir.c
*
* Creates, reads, walks and deletes directory-nodes
*
* Copyright (C) 2002, 2004 Oracle. All rights reserved.
*
* Portions of this code from linux/fs/ext3/dir.c
*
* Copyright (C) 1992, 1993, 1994, 1995
* Remy Card (card@masi.ibp.fr)
* Laboratoire MASI - Institut Blaise pascal
* Universite Pierre et Marie Curie (Paris VI)
*
* from
*
* linux/fs/minix/dir.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*/
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/highmem.h>
#include <linux/quotaops.h>
#include <linux/sort.h>
#include <cluster/masklog.h>
#include "ocfs2.h"
#include "alloc.h"
#include "blockcheck.h"
#include "dir.h"
#include "dlmglue.h"
#include "extent_map.h"
#include "file.h"
#include "inode.h"
#include "journal.h"
#include "namei.h"
#include "suballoc.h"
#include "super.h"
#include "sysfile.h"
#include "uptodate.h"
#include "ocfs2_trace.h"
#include "buffer_head_io.h"
#define NAMEI_RA_CHUNKS 2
#define NAMEI_RA_BLOCKS 4
#define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS)
static unsigned char ocfs2_filetype_table[] = {
DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
};
static int ocfs2_do_extend_dir(struct super_block *sb,
handle_t *handle,
struct inode *dir,
struct buffer_head *parent_fe_bh,
struct ocfs2_alloc_context *data_ac,
struct ocfs2_alloc_context *meta_ac,
struct buffer_head **new_bh);
static int ocfs2_dir_indexed(struct inode *inode);
/*
* These are distinct checks because future versions of the file system will
* want to have a trailing dirent structure independent of indexing.
*/
static int ocfs2_supports_dir_trailer(struct inode *dir)
{
struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
return 0;
return ocfs2_meta_ecc(osb) || ocfs2_dir_indexed(dir);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 48 | 100.00% | 2 | 100.00% |
| Total | 48 | 100.00% | 2 | 100.00% |
/*
* "new' here refers to the point at which we're creating a new
* directory via "mkdir()", but also when we're expanding an inline
* directory. In either case, we don't yet have the indexing bit set
* on the directory, so the standard checks will fail in when metaecc
* is turned off. Only directory-initialization type functions should
* use this then. Everything else wants ocfs2_supports_dir_trailer()
*/
static int ocfs2_new_dir_wants_trailer(struct inode *dir)
{
struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
return ocfs2_meta_ecc(osb) ||
ocfs2_supports_indexed_dirs(osb);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 34 | 100.00% | 2 | 100.00% |
| Total | 34 | 100.00% | 2 | 100.00% |
static inline unsigned int ocfs2_dir_trailer_blk_off(struct super_block *sb)
{
return sb->s_blocksize - sizeof(struct ocfs2_dir_block_trailer);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 24 | 100.00% | 1 | 100.00% |
| Total | 24 | 100.00% | 1 | 100.00% |
#define ocfs2_trailer_from_bh(_bh, _sb) ((struct ocfs2_dir_block_trailer *) ((_bh)->b_data + ocfs2_dir_trailer_blk_off((_sb))))
/* XXX ocfs2_block_dqtrailer() is similar but not quite - can we make
* them more consistent? */
struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
void *data)
{
char *p = data;
p += blocksize - sizeof(struct ocfs2_dir_block_trailer);
return (struct ocfs2_dir_block_trailer *)p;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
joel becker | joel becker | 38 | 100.00% | 1 | 100.00% |
| Total | 38 | 100.00% | 1 | 100.00% |
/*
* XXX: This is executed once on every dirent. We should consider optimizing
* it.
*/
static int ocfs2_skip_dir_trailer(struct inode *dir,
struct ocfs2_dir_entry *de,
unsigned long offset,
unsigned long blklen)
{
unsigned long toff = blklen - sizeof(struct ocfs2_dir_block_trailer);
if (!ocfs2_supports_dir_trailer(dir))
return 0;
if (offset != toff)
return 0;
return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 59 | 100.00% | 2 | 100.00% |
| Total | 59 | 100.00% | 2 | 100.00% |
static void ocfs2_init_dir_trailer(struct inode *inode,
struct buffer_head *bh, u16 rec_len)
{
struct ocfs2_dir_block_trailer *trailer;
trailer = ocfs2_trailer_from_bh(bh, inode->i_sb);
strcpy(trailer->db_signature, OCFS2_DIR_TRAILER_SIGNATURE);
trailer->db_compat_rec_len =
cpu_to_le16(sizeof(struct ocfs2_dir_block_trailer));
trailer->db_parent_dinode = cpu_to_le64(OCFS2_I(inode)->ip_blkno);
trailer->db_blkno = cpu_to_le64(bh->b_blocknr);
trailer->db_free_rec_len = cpu_to_le16(rec_len);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 91 | 100.00% | 2 | 100.00% |
| Total | 91 | 100.00% | 2 | 100.00% |
/*
* Link an unindexed block with a dir trailer structure into the index free
* list. This function will modify dirdata_bh, but assumes you've already
* passed it to the journal.
*/
static int ocfs2_dx_dir_link_trailer(struct inode *dir, handle_t *handle,
struct buffer_head *dx_root_bh,
struct buffer_head *dirdata_bh)
{
int ret;
struct ocfs2_dx_root_block *dx_root;
struct ocfs2_dir_block_trailer *trailer;
ret = ocfs2_journal_access_dr(handle, INODE_CACHE(dir), dx_root_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret) {
mlog_errno(ret);
goto out;
}
trailer = ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb);
dx_root = (struct ocfs2_dx_root_block *)dx_root_bh->b_data;
trailer->db_free_next = dx_root->dr_free_blk;
dx_root->dr_free_blk = cpu_to_le64(dirdata_bh->b_blocknr);
ocfs2_journal_dirty(handle, dx_root_bh);
out:
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 118 | 97.52% | 1 | 50.00% |
joel becker | joel becker | 3 | 2.48% | 1 | 50.00% |
| Total | 121 | 100.00% | 2 | 100.00% |
static int ocfs2_free_list_at_root(struct ocfs2_dir_lookup_result *res)
{
return res->dl_prev_leaf_bh == NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 18 | 100.00% | 2 | 100.00% |
| Total | 18 | 100.00% | 2 | 100.00% |
void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res)
{
brelse(res->dl_dx_root_bh);
brelse(res->dl_leaf_bh);
brelse(res->dl_dx_leaf_bh);
brelse(res->dl_prev_leaf_bh);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 38 | 100.00% | 4 | 100.00% |
| Total | 38 | 100.00% | 4 | 100.00% |
static int ocfs2_dir_indexed(struct inode *inode)
{
if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INDEXED_DIR_FL)
return 1;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 28 | 100.00% | 4 | 100.00% |
| Total | 28 | 100.00% | 4 | 100.00% |
static inline int ocfs2_dx_root_inline(struct ocfs2_dx_root_block *dx_root)
{
return dx_root->dr_flags & OCFS2_DX_FLAG_INLINE;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 19 | 100.00% | 1 | 100.00% |
| Total | 19 | 100.00% | 1 | 100.00% |
/*
* Hashing code adapted from ext3
*/
#define DELTA 0x9E3779B9
static void TEA_transform(__u32 buf[4], __u32 const in[])
{
__u32 sum = 0;
__u32 b0 = buf[0], b1 = buf[1];
__u32 a = in[0], b = in[1], c = in[2], d = in[3];
int n = 16;
do {
sum += DELTA;
b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b);
b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d);
} while (--n);
buf[0] += b0;
buf[1] += b1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 154 | 100.00% | 2 | 100.00% |
| Total | 154 | 100.00% | 2 | 100.00% |
static void str2hashbuf(const char *msg, int len, __u32 *buf, int num)
{
__u32 pad, val;
int i;
pad = (__u32)len | ((__u32)len << 8);
pad |= pad << 16;
val = pad;
if (len > num*4)
len = num * 4;
for (i = 0; i < len; i++) {
if ((i % 4) == 0)
val = pad;
val = msg[i] + (val << 8);
if ((i % 4) == 3) {
*buf++ = val;
val = pad;
num--;
}
}
if (--num >= 0)
*buf++ = val;
while (--num >= 0)
*buf++ = pad;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 162 | 100.00% | 3 | 100.00% |
| Total | 162 | 100.00% | 3 | 100.00% |
static void ocfs2_dx_dir_name_hash(struct inode *dir, const char *name, int len,
struct ocfs2_dx_hinfo *hinfo)
{
struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
const char *p;
__u32 in[8], buf[4];
/*
* XXX: Is this really necessary, if the index is never looked
* at by readdir? Is a hash value of '0' a bad idea?
*/
if ((len == 1 && !strncmp(".", name, 1)) ||
(len == 2 && !strncmp("..", name, 2))) {
buf[0] = buf[1] = 0;
goto out;
}
#ifdef OCFS2_DEBUG_DX_DIRS
/*
* This makes it very easy to debug indexing problems. We
* should never allow this to be selected without hand editing
* this file though.
*/
buf[0] = buf[1] = len;
goto out;
#endif
memcpy(buf, osb->osb_dx_seed, sizeof(buf));
p = name;
while (len > 0) {
str2hashbuf(p, len, in, 4);
TEA_transform(buf, in);
len -= 16;
p += 16;
}
out:
hinfo->major_hash = buf[0];
hinfo->minor_hash = buf[1];
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 197 | 100.00% | 3 | 100.00% |
| Total | 197 | 100.00% | 3 | 100.00% |
/*
* bh passed here can be an inode block or a dir data block, depending
* on the inode inline data flag.
*/
static int ocfs2_check_dir_entry(struct inode * dir,
struct ocfs2_dir_entry * de,
struct buffer_head * bh,
unsigned long offset)
{
const char *error_msg = NULL;
const int rlen = le16_to_cpu(de->rec_len);
if (unlikely(rlen < OCFS2_DIR_REC_LEN(1)))
error_msg = "rec_len is smaller than minimal";
else if (unlikely(rlen % 4 != 0))
error_msg = "rec_len % 4 != 0";
else if (unlikely(rlen < OCFS2_DIR_REC_LEN(de->name_len)))
error_msg = "rec_len is too small for name_len";
else if (unlikely(
((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize))
error_msg = "directory entry across blocks";
if (unlikely(error_msg != NULL))
mlog(ML_ERROR, "bad entry in directory #%llu: %s - "
"offset=%lu, inode=%llu, rec_len=%d, name_len=%d\n",
(unsigned long long)OCFS2_I(dir)->ip_blkno, error_msg,
offset, (unsigned long long)le64_to_cpu(de->inode), rlen,
de->name_len);
return error_msg == NULL ? 1 : 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 122 | 66.30% | 1 | 20.00% |
joel becker | joel becker | 47 | 25.54% | 3 | 60.00% |
tao ma | tao ma | 15 | 8.15% | 1 | 20.00% |
| Total | 184 | 100.00% | 5 | 100.00% |
static inline int ocfs2_match(int len,
const char * const name,
struct ocfs2_dir_entry *de)
{
if (len != de->name_len)
return 0;
if (!de->inode)
return 0;
return !memcmp(name, de->name, len);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 45 | 81.82% | 1 | 50.00% |
joel becker | joel becker | 10 | 18.18% | 1 | 50.00% |
| Total | 55 | 100.00% | 2 | 100.00% |
/*
* Returns 0 if not found, -1 on failure, and 1 on success
*/
static inline int ocfs2_search_dirblock(struct buffer_head *bh,
struct inode *dir,
const char *name, int namelen,
unsigned long offset,
char *first_de,
unsigned int bytes,
struct ocfs2_dir_entry **res_dir)
{
struct ocfs2_dir_entry *de;
char *dlimit, *de_buf;
int de_len;
int ret = 0;
de_buf = first_de;
dlimit = de_buf + bytes;
while (de_buf < dlimit) {
/* this code is executed quadratically often */
/* do minimal checking `by hand' */
de = (struct ocfs2_dir_entry *) de_buf;
if (de_buf + namelen <= dlimit &&
ocfs2_match(namelen, name, de)) {
/* found a match - just to be sure, do a full check */
if (!ocfs2_check_dir_entry(dir, de, bh, offset)) {
ret = -1;
goto bail;
}
*res_dir = de;
ret = 1;
goto bail;
}
/* prevent looping on a bad block */
de_len = le16_to_cpu(de->rec_len);
if (de_len <= 0) {
ret = -1;
goto bail;
}
de_buf += de_len;
offset += de_len;
}
bail:
trace_ocfs2_search_dirblock(ret);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 178 | 92.71% | 2 | 33.33% |
joel becker | joel becker | 12 | 6.25% | 2 | 33.33% |
tao ma | tao ma | 1 | 0.52% | 1 | 16.67% |
jesper juhl | jesper juhl | 1 | 0.52% | 1 | 16.67% |
| Total | 192 | 100.00% | 6 | 100.00% |
static struct buffer_head *ocfs2_find_entry_id(const char *name,
int namelen,
struct inode *dir,
struct ocfs2_dir_entry **res_dir)
{
int ret, found;
struct buffer_head *di_bh = NULL;
struct ocfs2_dinode *di;
struct ocfs2_inline_data *data;
ret = ocfs2_read_inode_block(dir, &di_bh);
if (ret) {
mlog_errno(ret);
goto out;
}
di = (struct ocfs2_dinode *)di_bh->b_data;
data = &di->id2.i_data;
found = ocfs2_search_dirblock(di_bh, dir, name, namelen, 0,
data->id_data, i_size_read(dir), res_dir);
if (found == 1)
return di_bh;
brelse(di_bh);
out:
return NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 136 | 98.55% | 3 | 60.00% |
adrian bunk | adrian bunk | 1 | 0.72% | 1 | 20.00% |
joel becker | joel becker | 1 | 0.72% | 1 | 20.00% |
| Total | 138 | 100.00% | 5 | 100.00% |
static int ocfs2_validate_dir_block(struct super_block *sb,
struct buffer_head *bh)
{
int rc;
struct ocfs2_dir_block_trailer *trailer =
ocfs2_trailer_from_bh(bh, sb);
/*
* We don't validate dirents here, that's handled
* in-place when the code walks them.
*/
trace_ocfs2_validate_dir_block((unsigned long long)bh->b_blocknr);
BUG_ON(!buffer_uptodate(bh));
/*
* If the ecc fails, we return the error but otherwise
* leave the filesystem running. We know any error is
* local to this block.
*
* Note that we are safe to call this even if the directory
* doesn't have a trailer. Filesystems without metaecc will do
* nothing, and filesystems with it will have one.
*/
rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &trailer->db_check);
if (rc)
mlog(ML_ERROR, "Checksum failed for dinode %llu\n",
(unsigned long long)bh->b_blocknr);
return rc;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 91 | 97.85% | 3 | 60.00% |
tao ma | tao ma | 1 | 1.08% | 1 | 20.00% |
joel becker | joel becker | 1 | 1.08% | 1 | 20.00% |
| Total | 93 | 100.00% | 5 | 100.00% |
/*
* Validate a directory trailer.
*
* We check the trailer here rather than in ocfs2_validate_dir_block()
* because that function doesn't have the inode to test.
*/
static int ocfs2_check_dir_trailer(struct inode *dir, struct buffer_head *bh)
{
int rc = 0;
struct ocfs2_dir_block_trailer *trailer;
trailer = ocfs2_trailer_from_bh(bh, dir->i_sb);
if (!OCFS2_IS_VALID_DIR_TRAILER(trailer)) {
rc = ocfs2_error(dir->i_sb,
"Invalid dirblock #%llu: signature = %.*s\n",
(unsigned long long)bh->b_blocknr, 7,
trailer->db_signature);
goto out;
}
if (le64_to_cpu(trailer->db_blkno) != bh->b_blocknr) {
rc = ocfs2_error(dir->i_sb,
"Directory block #%llu has an invalid db_blkno of %llu\n",
(unsigned long long)bh->b_blocknr,
(unsigned long long)le64_to_cpu(trailer->db_blkno));
goto out;
}
if (le64_to_cpu(trailer->db_parent_dinode) !=
OCFS2_I(dir)->ip_blkno) {
rc = ocfs2_error(dir->i_sb,
"Directory block #%llu on dinode #%llu has an invalid parent_dinode of %llu\n",
(unsigned long long)bh->b_blocknr,
(unsigned long long)OCFS2_I(dir)->ip_blkno,
(unsigned long long)le64_to_cpu(trailer->db_blkno));
goto out;
}
out:
return rc;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 193 | 98.47% | 3 | 75.00% |
joe perches | joe perches | 3 | 1.53% | 1 | 25.00% |
| Total | 196 | 100.00% | 4 | 100.00% |
/*
* This function forces all errors to -EIO for consistency with its
* predecessor, ocfs2_bread(). We haven't audited what returning the
* real error codes would do to callers. We log the real codes with
* mlog_errno() before we squash them.
*/
static int ocfs2_read_dir_block(struct inode *inode, u64 v_block,
struct buffer_head **bh, int flags)
{
int rc = 0;
struct buffer_head *tmp = *bh;
rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, flags,
ocfs2_validate_dir_block);
if (rc) {
mlog_errno(rc);
goto out;
}
if (!(flags & OCFS2_BH_READAHEAD) &&
ocfs2_supports_dir_trailer(inode)) {
rc = ocfs2_check_dir_trailer(inode, tmp);
if (rc) {
if (!*bh)
brelse(tmp);
mlog_errno(rc);
goto out;
}
}
/* If ocfs2_read_virt_blocks() got us a new bh, pass it up. */
if (!*bh)
*bh = tmp;
out:
return rc ? -EIO : 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 140 | 100.00% | 4 | 100.00% |
| Total | 140 | 100.00% | 4 | 100.00% |
/*
* Read the block at 'phys' which belongs to this directory
* inode. This function does no virtual->physical block translation -
* what's passed in is assumed to be a valid directory block.
*/
static int ocfs2_read_dir_block_direct(struct inode *dir, u64 phys,
struct buffer_head **bh)
{
int ret;
struct buffer_head *tmp = *bh;
ret = ocfs2_read_block(INODE_CACHE(dir), phys, &tmp,
ocfs2_validate_dir_block);
if (ret) {
mlog_errno(ret);
goto out;
}
if (ocfs2_supports_dir_trailer(dir)) {
ret = ocfs2_check_dir_trailer(dir, tmp);
if (ret) {
if (!*bh)
brelse(tmp);
mlog_errno(ret);
goto out;
}
}
if (!ret && !*bh)
*bh = tmp;
out:
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 118 | 95.16% | 3 | 60.00% |
joel becker | joel becker | 6 | 4.84% | 2 | 40.00% |
| Total | 124 | 100.00% | 5 | 100.00% |
static int ocfs2_validate_dx_root(struct super_block *sb,
struct buffer_head *bh)
{
int ret;
struct ocfs2_dx_root_block *dx_root;
BUG_ON(!buffer_uptodate(bh));
dx_root = (struct ocfs2_dx_root_block *) bh->b_data;
ret = ocfs2_validate_meta_ecc(sb, bh->b_data, &dx_root->dr_check);
if (ret) {
mlog(ML_ERROR,
"Checksum failed for dir index root block %llu\n",
(unsigned long long)bh->b_blocknr);
return ret;
}
if (!OCFS2_IS_VALID_DX_ROOT(dx_root)) {
ret = ocfs2_error(sb,
"Dir Index Root # %llu has bad signature %.*s\n",
(unsigned long long)le64_to_cpu(dx_root->dr_blkno),
7, dx_root->dr_signature);
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 121 | 96.80% | 3 | 60.00% |
goldwyn rodrigues | goldwyn rodrigues | 3 | 2.40% | 1 | 20.00% |
joe perches | joe perches | 1 | 0.80% | 1 | 20.00% |
| Total | 125 | 100.00% | 5 | 100.00% |
static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di,
struct buffer_head **dx_root_bh)
{
int ret;
u64 blkno = le64_to_cpu(di->i_dx_root);
struct buffer_head *tmp = *dx_root_bh;
ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp,
ocfs2_validate_dx_root);
/* If ocfs2_read_block() got us a new bh, pass it up. */
if (!ret && !*dx_root_bh)
*dx_root_bh = tmp;
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 75 | 96.15% | 3 | 75.00% |
joel becker | joel becker | 3 | 3.85% | 1 | 25.00% |
| Total | 78 | 100.00% | 4 | 100.00% |
static int ocfs2_validate_dx_leaf(struct super_block *sb,
struct buffer_head *bh)
{
int ret;
struct ocfs2_dx_leaf *dx_leaf = (struct ocfs2_dx_leaf *)bh->b_data;
BUG_ON(!buffer_uptodate(bh));
ret = ocfs2_validate_meta_ecc(sb, bh->b_data, &dx_leaf->dl_check);
if (ret) {
mlog(ML_ERROR,
"Checksum failed for dir index leaf block %llu\n",
(unsigned long long)bh->b_blocknr);
return ret;
}
if (!OCFS2_IS_VALID_DX_LEAF(dx_leaf)) {
ret = ocfs2_error(sb, "Dir Index Leaf has bad signature %.*s\n",
7, dx_leaf->dl_signature);
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 107 | 96.40% | 4 | 66.67% |
goldwyn rodrigues | goldwyn rodrigues | 3 | 2.70% | 1 | 16.67% |
joe perches | joe perches | 1 | 0.90% | 1 | 16.67% |
| Total | 111 | 100.00% | 6 | 100.00% |
static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno,
struct buffer_head **dx_leaf_bh)
{
int ret;
struct buffer_head *tmp = *dx_leaf_bh;
ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp,
ocfs2_validate_dx_leaf);
/* If ocfs2_read_block() got us a new bh, pass it up. */
if (!ret && !*dx_leaf_bh)
*dx_leaf_bh = tmp;
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 63 | 95.45% | 2 | 66.67% |
joel becker | joel becker | 3 | 4.55% | 1 | 33.33% |
| Total | 66 | 100.00% | 3 | 100.00% |
/*
* Read a series of dx_leaf blocks. This expects all buffer_head
* pointers to be NULL on function entry.
*/
static int ocfs2_read_dx_leaves(struct inode *dir, u64 start, int num,
struct buffer_head **dx_leaf_bhs)
{
int ret;
ret = ocfs2_read_blocks(INODE_CACHE(dir), start, num, dx_leaf_bhs, 0,
ocfs2_validate_dx_leaf);
if (ret)
mlog_errno(ret);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark fasheh | mark fasheh | 55 | 94.83% | 2 | 66.67% |
joel becker | joel becker | 3 | 5.17% | 1 | 33.33% |
| Total | 58 | 100.00% | 3 | 100.00% |
static struct buffer_head *ocfs2_find_entry_el(const char *name, int namelen,
struct inode *dir,
struct ocfs2_dir_entry **res_dir)
{
struct super_block *sb;
struct buffer_head *bh_use[NAMEI_RA_SIZE];
struct buffer_head *bh, *ret = NULL;
unsigned long start, block, b;
int ra_max = 0; /* Number of bh's in the readahead
buffer, bh_use[] */
int ra_ptr = 0; /* Current index into readahead
buffer */
int num = 0;
int nblocks, i, err;
sb = dir->i_sb;
nblocks = i_size_read(dir) >> sb->s_blocksize_bits;
start = OCFS2_I(dir)->ip_dir_start_lookup;
if (start >= nblocks)
start = 0;
block = start;
restart:
do {
/*
* We deal with the read-ahead logic here.
*/
if (ra_ptr >= ra_max) {