]) # LC_HAVE_BLK_PLUG
#
-# LC_IOP_TRUNCATE
-#
-# truncate callback removed since 2.6.39
-#
-AC_DEFUN([LC_IOP_TRUNCATE], [
-LB_CHECK_COMPILE([if 'inode_operations' has '.truncate' member function],
-inode_ops_truncate, [
- #include <linux/fs.h>
-],[
- ((struct inode_operations *)0)->truncate(NULL);
-],[
- AC_DEFINE(HAVE_INODEOPS_TRUNCATE, 1,
- [inode_operations has .truncate member function])
-])
-]) # LC_IOP_TRUNCATE
-
-#
# LC_HAVE_FSTYPE_MOUNT
#
# 2.6.39 replace get_sb with mount in struct file_system_type
]) # LC_IOP_SET_ACL
#
-# LC_HAVE_BI_CNT
-#
-# 4.4 redefined bi_cnt as __bi_cnt
-#
-AC_DEFUN([LC_HAVE_BI_CNT], [
-LB_CHECK_COMPILE([if Linux kernel has bi_cnt in struct bio],
-have_bi_cnt, [
- #include <asm/atomic.h>
- #include <linux/bio.h>
-],[
- struct bio bio = { };
- int cnt;
- cnt = atomic_read(&bio.bi_cnt);
-], [
- AC_DEFINE(HAVE_BI_CNT, 1,
- [struct bio has bi_cnt])
-])
-]) # LC_HAVE_BI_CNT
-
-#
-# LC_HAVE_BI_RW
-#
-# 4.4 redefined bi_rw as bi_opf
-#
-AC_DEFUN([LC_HAVE_BI_RW], [
-LB_CHECK_COMPILE([if Linux kernel has bi_rw in struct bio],
-have_bi_rw, [
- #include <linux/bio.h>
-],[
- struct bio bio;
-
- bio.bi_rw = 0;
-], [
- AC_DEFINE(HAVE_BI_RW, 1,
- [struct bio has bi_rw])
-])
-]) # LC_HAVE_BI_RW
-
-#
-# LC_HAVE_SUBMIT_BIO_2ARGS
-#
-# 4.4 removed an argument from submit_bio
-#
-AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
-LB_CHECK_COMPILE([if submit_bio takes two arguments],
-have_submit_bio_2args, [
- #include <linux/bio.h>
-],[
- struct bio bio;
- submit_bio(READ, &bio);
-], [
- AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
- [submit_bio takes two arguments])
-])
-]) # LC_HAVE_SUBMIT_BIO_2_ARGS
-
-#
-# LC_HAVE_CLEAN_BDEV_ALIASES
-#
-# 4.4 unmap_underlying_metadata was replaced by clean_bdev_aliases
-#
-AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
-LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
-have_clean_bdev_aliases, [
- #include <linux/buffer_head.h>
-],[
- struct block_device bdev;
- clean_bdev_aliases(&bdev,1,1);
-], [
- AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
- [kernel has clean_bdev_aliases])
-])
-]) # LC_HAVE_CLEAN_BDEV_ALIASES
-
-#
# LC_HAVE_TRUNCATE_IPAGE_FINAL
#
# 3.14 bring truncate_inode_pages_final for evict_inode
]) # LC_HAVE_SYNC_READ_WRITE
#
+# LC_HAVE___BI_CNT
+#
+# 4.1 redefined bi_cnt as __bi_cnt in commit dac56212e8127dbc0
+#
+AC_DEFUN([LC_HAVE___BI_CNT], [
+LB_CHECK_COMPILE([if Linux kernel has __bi_cnt in struct bio],
+have___bi_cnt, [
+ #include <asm/atomic.h>
+ #include <linux/bio.h>
+ #include <linux/blk_types.h>
+],[
+ struct bio bio = { };
+ int cnt;
+ cnt = atomic_read(&bio.__bi_cnt);
+], [
+ AC_DEFINE(HAVE___BI_CNT, 1,
+ [struct bio has __bi_cnt])
+])
+]) # LC_HAVE___BI_CNT
+
+#
# LC_NEW_CANCEL_DIRTY_PAGE
#
# 4.2 kernel has new cancel_dirty_page
]) # LC_BIO_INTEGRITY_PREP_FN
#
+# LC_HAVE_BI_OPF
+#
+# 4.4/4.8 redefined bi_rw as bi_opf (SLES12/kernel commit 4382e33ad37486)
+#
+AC_DEFUN([LC_HAVE_BI_OPF], [
+LB_CHECK_COMPILE([if Linux kernel has bi_opf in struct bio],
+have_bi_opf, [
+ #include <linux/bio.h>
+],[
+ struct bio bio;
+
+ bio.bi_opf = 0;
+], [
+ AC_DEFINE(HAVE_BI_OPF, 1,
+ [struct bio has bi_opf])
+])
+]) # LC_HAVE_BI_OPF
+
+#
+# LC_HAVE_SUBMIT_BIO_2ARGS
+#
+# 4.4 removed an argument from submit_bio
+#
+AC_DEFUN([LC_HAVE_SUBMIT_BIO_2ARGS], [
+LB_CHECK_COMPILE([if submit_bio takes two arguments],
+have_submit_bio_2args, [
+ #include <linux/bio.h>
+],[
+ struct bio bio;
+ submit_bio(READ, &bio);
+], [
+ AC_DEFINE(HAVE_SUBMIT_BIO_2ARGS, 1,
+ [submit_bio takes two arguments])
+])
+]) # LC_HAVE_SUBMIT_BIO_2_ARGS
+
+#
+# LC_HAVE_CLEAN_BDEV_ALIASES
+#
+# 4.4/4.9 unmap_underlying_metadata was replaced by clean_bdev_aliases
+# (SLES12/kernel commit 29f3ad7d8380364c)
+#
+AC_DEFUN([LC_HAVE_CLEAN_BDEV_ALIASES], [
+LB_CHECK_COMPILE([if kernel has clean_bdev_aliases],
+have_clean_bdev_aliases, [
+ #include <linux/buffer_head.h>
+],[
+ struct block_device bdev;
+ clean_bdev_aliases(&bdev,1,1);
+], [
+ AC_DEFINE(HAVE_CLEAN_BDEV_ALIASES, 1,
+ [kernel has clean_bdev_aliases])
+])
+]) # LC_HAVE_CLEAN_BDEV_ALIASES
+
+#
# LC_HAVE_LOCKS_LOCK_FILE_WAIT
#
# 4.4 kernel have moved locks API users to
# 2.6.39
LC_HAVE_FHANDLE_SYSCALLS
LC_HAVE_FSTYPE_MOUNT
- LC_IOP_TRUNCATE
LC_HAVE_INODE_OWNER_OR_CAPABLE
LC_HAVE_SECURITY_IINITSEC
# 4.1.0
LC_IOV_ITER_RW
LC_HAVE_SYNC_READ_WRITE
+ LC_HAVE___BI_CNT
# 4.2
LC_NEW_CANCEL_DIRTY_PAGE
LC_HAVE_LOCKS_LOCK_FILE_WAIT
LC_HAVE_KEY_PAYLOAD_DATA_ARRAY
LC_HAVE_XATTR_HANDLER_NAME
- LC_HAVE_BI_CNT
- LC_HAVE_BI_RW
+ LC_HAVE_BI_OPF
LC_HAVE_SUBMIT_BIO_2ARGS
LC_HAVE_CLEAN_BDEV_ALIASES
#ifndef HAVE_BIO_INTEGRITY_ENABLED
bool bio_integrity_enabled(struct bio *bio)
{
-# ifdef HAVE_BI_BDEV
- struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
-# else
- struct blk_integrity *bi = blk_get_integrity(bio->bi_disk);
-# endif
+ struct blk_integrity *bi = blk_get_integrity(bio_get_disk(bio));
if (bio_op(bio) != REQ_OP_READ && bio_op(bio) != REQ_OP_WRITE)
return false;
#endif
#ifdef HAVE_BI_BDEV
-# define bio_set_dev(bio, bdev) ((bio)->bi_bdev = bdev)
-# define bio_get_queue(bio) bdev_get_queue((bio)->bi_bdev)
+# define bio_get_dev(bio) ((bio)->bi_bdev)
+# define bio_get_disk(bio) (bio_get_dev(bio)->bd_disk)
+# define bio_get_queue(bio) bdev_get_queue(bio_get_dev(bio))
+# define bio_set_dev(bio, bdev) (bio_get_dev(bio) = (bdev))
#else
-# define bio_get_queue(bio) ((bio)->bi_disk->queue)
+# define bio_get_disk(bio) ((bio)->bi_disk)
+# define bio_get_queue(bio) (bio_get_disk(bio)->queue)
#endif
void ldiskfs_inc_count(handle_t *handle, struct inode *inode);
void osd_process_truncates(struct list_head *list);
void osd_execute_truncate(struct osd_object *obj);
+#ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
+#define osd_dio_complete_routine(bio, error) dio_complete_routine(bio)
+#else
+#define osd_dio_complete_routine(bio, error) dio_complete_routine(bio, error)
+#endif
+
+#ifndef HAVE___BI_CNT
+#define __bi_cnt bi_cnt
+#endif
+
+#ifndef HAVE_BI_OPF
+#define bi_opf bi_rw
+#endif
+
+#ifndef HAVE_CLEAN_BDEV_ALIASES
+#define clean_bdev_aliases(bdev, block, len) \
+ unmap_underlying_metadata((bdev), (block))
+#endif
+
+#ifndef HAVE_BI_STATUS
+#define bi_status bi_error
+#endif
+
/*
* Maximum size of xattr attributes for FEATURE_INCOMPAT_EA_INODE 1Mb
* This limit is arbitrary, but is reasonable for the xattr API.
int osd_get_integrity_profile(struct osd_device *osd,
integrity_gen_fn **generate_fn,
integrity_vrfy_fn **verify_fn);
+#else
+#define integrity_gen_fn void
+#define integrity_vrfy_fn int
+static inline int osd_get_integrity_profile(struct osd_device *osd,
+ integrity_gen_fn **generate_fn,
+ integrity_vrfy_fn **verify_fn)
+{
+ return 0;
+}
+
+static inline bool bio_integrity_prep_fn(struct bio *bio,
+ integrity_gen_fn *generate_fn,
+ integrity_vrfy_fn *verify_fn)
+{
+ return bio_integrity_prep(bio);
+}
#endif
#endif /* _OSD_INTERNAL_H */
#ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
static void dio_complete_routine(struct bio *bio)
{
-# ifdef HAVE_BI_STATUS
int error = bio->bi_status;
-# else
- int error = bio->bi_error;
-# endif
#else
static void dio_complete_routine(struct bio *bio, int error)
{
"(like SCSI errors, perhaps). Because bi_private is "
"NULL, I can't wake up the thread that initiated this "
"IO - you will probably have to reboot this node.\n");
- CERROR("bi_next: %p, bi_flags: %lx, "
-#ifdef HAVE_BI_RW
- "bi_rw: %lu,"
-#else
- "bi_opf: %u,"
-#endif
- "bi_vcnt: %d, bi_idx: %d, bi->size: %d, bi_end_io: %p,"
- "bi_cnt: %d, bi_private: %p\n", bio->bi_next,
- (unsigned long)bio->bi_flags,
-#ifdef HAVE_BI_RW
- bio->bi_rw,
-#else
- bio->bi_opf,
-#endif
- bio->bi_vcnt, bio_idx(bio),
- bio_sectors(bio) << 9, bio->bi_end_io,
-#ifdef HAVE_BI_CNT
- atomic_read(&bio->bi_cnt),
-#else
- atomic_read(&bio->__bi_cnt),
-#endif
- bio->bi_private);
+ CERROR("bi_next: %p, bi_flags: %lx, " __stringify(bi_opf)
+ ": %x, bi_vcnt: %d, bi_idx: %d, bi->size: %d, bi_end_io: %p, bi_cnt: %d, bi_private: %p\n",
+ bio->bi_next, (unsigned long)bio->bi_flags,
+ (unsigned int)bio->bi_opf, bio->bi_vcnt, bio_idx(bio),
+ bio_sectors(bio) << 9, bio->bi_end_io,
+ atomic_read(&bio->__bi_cnt),
+ bio->bi_private);
return;
}
static void osd_submit_bio(int rw, struct bio *bio)
{
- LASSERTF(rw == 0 || rw == 1, "%x\n", rw);
+ LASSERTF(rw == 0 || rw == 1, "%x\n", rw);
#ifdef HAVE_SUBMIT_BIO_2ARGS
- if (rw == 0)
- submit_bio(READ, bio);
- else
- submit_bio(WRITE, bio);
+ submit_bio(rw ? WRITE : READ, bio);
#else
- bio->bi_opf |= rw;
- submit_bio(bio);
+ bio->bi_opf |= rw;
+ submit_bio(bio);
#endif
}
bool integrity_enabled)
{
struct super_block *sb = osd_sb(osd);
- int rc;
-#ifdef HAVE_BIO_INTEGRITY_PREP_FN
integrity_gen_fn *generate_fn = NULL;
integrity_vrfy_fn *verify_fn = NULL;
-#endif
+ int rc;
ENTRY;
if (!integrity_enabled)
RETURN(0);
-#ifdef HAVE_BIO_INTEGRITY_PREP_FN
rc = osd_get_integrity_profile(osd, &generate_fn, &verify_fn);
if (rc)
RETURN(rc);
rc = bio_integrity_prep_fn(bio, generate_fn, verify_fn);
-#else
- rc = bio_integrity_prep(bio);
-#endif
if (rc)
RETURN(rc);
#ifdef HAVE_BIO_INTEGRITY_PREP_FN
# ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
static void dio_integrity_complete_routine(struct bio *bio)
-{
# else
static void dio_integrity_complete_routine(struct bio *bio, int error)
-{
# endif
+{
struct osd_bio_private *bio_private = bio->bi_private;
bio->bi_private = bio_private->obp_iobuf;
-# ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
- dio_complete_routine(bio);
-# else
- dio_complete_routine(bio, error);
-# endif
+ osd_dio_complete_routine(bio, error);
OBD_FREE_PTR(bio_private);
}
bool integrity_enabled, int start_page_idx,
struct osd_bio_private **pprivate)
{
-#ifdef HAVE_BIO_INTEGRITY_PREP_FN
- struct osd_bio_private *bio_private;
-
ENTRY;
*pprivate = NULL;
+
+#ifdef HAVE_BIO_INTEGRITY_PREP_FN
if (integrity_enabled) {
+ struct osd_bio_private *bio_private = NULL;
+
OBD_ALLOC_GFP(bio_private, sizeof(*bio_private), GFP_NOIO);
if (bio_private == NULL)
RETURN(-ENOMEM);
bio_private->obp_start_page_idx = start_page_idx;
bio_private->obp_iobuf = iobuf;
*pprivate = bio_private;
- } else {
+ } else
+#endif
+ {
bio->bi_end_io = dio_complete_routine;
bio->bi_private = iobuf;
}
- RETURN(0);
-#else
- ENTRY;
- bio->bi_end_io = dio_complete_routine;
- bio->bi_private = iobuf;
RETURN(0);
-#endif
}
static int osd_do_bio(struct osd_device *osd, struct inode *inode,
bio_set_dev(bio, bdev);
bio_set_sector(bio, sector);
-#ifdef HAVE_BI_RW
- bio->bi_rw = (iobuf->dr_rw == 0) ? READ : WRITE;
-#else
- bio->bi_opf = (iobuf->dr_rw == 0) ? READ : WRITE;
-#endif
+ bio->bi_opf = iobuf->dr_rw ? WRITE : READ;
rc = osd_bio_init(bio, iobuf, integrity_enabled,
bio_start_page_idx, &bio_private);
if (rc) {
i, cex->ec_len);
for (; i < cex->ec_len && bp->num; i++) {
*(bp->blocks) = cex->ec_start + i;
- if (pblock != 0) {
- /* unmap any possible underlying metadata from
- * the block device mapping. bug 6998. */
-#ifndef HAVE_CLEAN_BDEV_ALIASES
- unmap_underlying_metadata(inode->i_sb->s_bdev,
- *(bp->blocks));
-#else
+ /* unmap any underlying metadata from
+ * the block device mapping. b=6998.
+ */
+ if (pblock != 0)
clean_bdev_aliases(inode->i_sb->s_bdev,
*(bp->blocks), 1);
-#endif
- }
bp->blocks++;
bp->num--;
bp->start++;
* mapping. bug 6998. */
if ((map.m_flags & LDISKFS_MAP_NEW) &&
create)
-#ifndef HAVE_CLEAN_BDEV_ALIASES
- unmap_underlying_metadata(
- inode->i_sb->s_bdev,
- map.m_pblk + c);
-#else
clean_bdev_aliases(
inode->i_sb->s_bdev,
map.m_pblk + c, 1);
-#endif
}
}
rc = 0;
return;
}
-#ifdef HAVE_INODEOPS_TRUNCATE
- if (inode->i_op->truncate)
- inode->i_op->truncate(inode);
- else
-#endif
- ldiskfs_truncate(inode);
+ ldiskfs_truncate(inode);
/*
* For a partial-page truncate, flush the page to disk immediately to