])
#
+# LB_EXT4_BREAD_4ARGS
+#
+# 3.18 ext4_bread has 4 arguments
+#
+AC_DEFUN([LB_EXT4_BREAD_4ARGS], [
+LB_CHECK_COMPILE([if ext4_bread takes 4 arguments],
+ext4_bread, [
+ #include <linux/fs.h>
+ #include "$EXT4_SRC_DIR/ext4.h"
+],[
+ ext4_bread(NULL, NULL, 0, 0);
+],[
+ AC_DEFINE(HAVE_EXT4_BREAD_4ARGS, 1, [ext4_bread takes 4 arguments])
+])
+]) # LB_EXT4_BREAD_4ARGS
+
+#
# LDISKFS_AC_PATCH_PROGRAM
#
# Determine which program should be used to apply the patches to
LB_EXT_PBLOCK
LB_EXT4_JOURNAL_START_3ARGS
LB_LDISKFS_MAP_BLOCKS
+ LB_EXT4_BREAD_4ARGS
AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [posix acls for ldiskfs])
AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [fs security for ldiskfs])
AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [extened attributes for ldiskfs])
struct inode *inode = c->ic_object;
struct iam_idle_head *head;
struct buffer_head *bh;
- int err = 0;
LASSERT(mutex_is_locked(&c->ic_idle_mutex));
if (blk == 0)
return NULL;
- bh = ldiskfs_bread(NULL, inode, blk, 0, &err);
- if (bh == NULL) {
- CERROR("%.16s: cannot load idle blocks, blk = %u, err = %d\n",
- LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk, err);
+ bh = __ldiskfs_bread(NULL, inode, blk, 0);
+ if (IS_ERR_OR_NULL(bh)) {
+ CERROR("%.16s: cannot load idle blocks, blk = %u, err = %ld\n",
+ LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk,
+ bh ? PTR_ERR(bh) : -EIO);
c->ic_idle_failed = 1;
- err = err ? err : -EIO;
- return ERR_PTR(err);
+ if (bh == NULL)
+ bh = ERR_PTR(-EIO);
+ return bh;
}
head = (struct iam_idle_head *)(bh->b_data);
int iam_node_read(struct iam_container *c, iam_ptr_t ptr,
handle_t *h, struct buffer_head **bh)
{
- int result = 0;
-
/* NB: it can be called by iam_lfix_guess() which is still at
* very early stage, c->ic_root_bh and c->ic_descr->id_ops
* haven't been intialized yet.
return 0;
}
- *bh = ldiskfs_bread(h, c->ic_object, (int)ptr, 0, &result);
- if (*bh == NULL)
- result = result ? result : -EIO;
- return result;
+ *bh = __ldiskfs_bread(h, c->ic_object, (int)ptr, 0);
+ if (IS_ERR(*bh))
+ return PTR_ERR(*bh);
+
+ if (*bh == NULL)
+ return -EIO;
+
+ return 0;
}
/*
goto fail;
mutex_unlock(&c->ic_idle_mutex);
- bh = ldiskfs_bread(NULL, inode, *b, 0, e);
- if (bh == NULL) {
- *e = *e ? *e : -EIO;
+ bh = __ldiskfs_bread(NULL, inode, *b, 0);
+ if (IS_ERR_OR_NULL(bh)) {
+ if (IS_ERR(bh))
+ *e = PTR_ERR(bh);
+ else
+ *e = -EIO;
return NULL;
}
goto got;
return dev->od_mdt_map->omm_remote_parent->d_inode->i_ino;
}
+/**
+ * ext4_bread/ldiskfs_bread has either 5 or 4 parameters. The error
+ * return code has been removed and integrated into the pointer in the
+ * kernel 3.18.
+ */
+static inline struct buffer_head *__ldiskfs_bread(handle_t *handle,
+ struct inode *inode,
+ ldiskfs_lblk_t block,
+ int create)
+{
+#ifdef HAVE_EXT4_BREAD_4ARGS
+ return ldiskfs_bread(handle, inode, block, create);
+#else
+ struct buffer_head *bh;
+ int error = 0;
+
+ bh = ldiskfs_bread(handle, inode, block, create, &error);
+ if (bh == NULL && error != 0)
+ bh = ERR_PTR(error);
+
+ return bh;
+#endif
+}
+
void ldiskfs_inc_count(handle_t *handle, struct inode *inode);
void ldiskfs_dec_count(handle_t *handle, struct inode *inode);
int blocksize;
int csize;
int boffs;
- int err = 0;
/* prevent reading after eof */
spin_lock(&inode->i_lock);
block = *offs >> inode->i_blkbits;
boffs = *offs & (blocksize - 1);
csize = min(blocksize - boffs, size);
- bh = ldiskfs_bread(NULL, inode, block, 0, &err);
- if (err != 0) {
- CERROR("%s: can't read %u@%llu on ino %lu: rc = %d\n",
+ bh = __ldiskfs_bread(NULL, inode, block, 0);
+ if (IS_ERR(bh)) {
+ CERROR("%s: can't read %u@%llu on ino %lu: rc = %ld\n",
LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
- csize, *offs, inode->i_ino, err);
- if (bh != NULL)
- brelse(bh);
- return err;
+ csize, *offs, inode->i_ino,
+ PTR_ERR(bh));
+ return PTR_ERR(bh);
}
if (bh != NULL) {
if (bh != NULL)
brelse(bh);
- block = offset >> inode->i_blkbits;
- boffs = offset & (blocksize - 1);
- size = min(blocksize - boffs, bufsize);
- bh = ldiskfs_bread(handle, inode, block, 1, &err);
- if (!bh) {
- err = err ? err : -EIO;
+ block = offset >> inode->i_blkbits;
+ boffs = offset & (blocksize - 1);
+ size = min(blocksize - boffs, bufsize);
+ bh = __ldiskfs_bread(handle, inode, block, 1);
+ if (IS_ERR_OR_NULL(bh)) {
+ if (bh == NULL) {
+ err = -EIO;
+ } else {
+ err = PTR_ERR(bh);
+ bh = NULL;
+ }
CERROR("%s: error reading offset %llu (block %lu): "
"rc = %d\n",
inode->i_sb->s_id, offset, block, err);
.dbo_fiemap_get = osd_fiemap_get,
.dbo_ladvise = osd_ladvise,
};
-