|
From: Ross S. W. W. <RW...@me...> - 2010-06-29 21:44:26
|
log2.h wasn't generally available until 2.6.21 release.
Added new compat.h file to hold global kernel compatibility
defines going forward.
Hopefully we can move some of the patches into either
compat.h or each modules own header file. digest.h would be a
good location for the shifting crypto API stuff, event.h for
the netlink stuff, and maybe a cache.h for the kernel object
cache.
Signed-off-by: Ross Walker
Index: kernel/block-io.c
===================================================================
--- kernel/block-io.c (revision 339)
+++ kernel/block-io.c (working copy)
@@ -282,8 +282,8 @@ blockio_attach(struct iet_volume *volume
/* see Documentation/ABI/testing/sysfs-block */
unsigned bsz = bdev_logical_block_size(bio_data->bdev);
if (!volume->blk_shift)
- volume->blk_shift = ilog2(bsz);
- else if (volume->blk_shift < ilog2(bsz)) {
+ volume->blk_shift = blksize_bits(bsz);
+ else if (volume->blk_shift < blksize_bits(bsz)) {
eprintk("Specified block size (%u) smaller than "
"device %s logical block size (%u)\n",
(1 << volume->blk_shift), bio_data->path, bsz);
Index: kernel/volume.c
===================================================================
--- kernel/volume.c (revision 339)
+++ kernel/volume.c (working copy)
@@ -6,7 +6,6 @@
#include <linux/types.h>
#include <linux/parser.h>
-#include <linux/log2.h>
#include "iscsi.h"
#include "iscsi_dbg.h"
@@ -187,7 +186,7 @@ static int parse_volume_params(struct ie
blk_sz = simple_strtoull(argp, NULL, 10);
if (is_power_of_2(blk_sz) &&
512 <= blk_sz && blk_sz <= IET_MAX_BLOCK_SIZE)
- volume->blk_shift = ilog2(blk_sz);
+ volume->blk_shift = blksize_bits(blk_sz);
else {
eprintk("invalid BlockSize=%u\n", blk_sz);
err = -EINVAL;
Index: kernel/null-io.c
===================================================================
--- kernel/null-io.c (revision 339)
+++ kernel/null-io.c (working copy)
@@ -78,7 +78,7 @@ static int nullio_attach(struct iet_volu
}
if (!lu->blk_shift)
- lu->blk_shift = ilog2(IET_DEF_BLOCK_SIZE);
+ lu->blk_shift = blksize_bits(IET_DEF_BLOCK_SIZE);
/* defaults to 64 GiB */
if (!lu->blk_cnt)
Index: kernel/iscsi.h
===================================================================
--- kernel/iscsi.h (revision 339)
+++ kernel/iscsi.h (working copy)
@@ -19,6 +19,7 @@
#include "iscsi_hdr.h"
#include "iet_u.h"
+#include "compat.h"
#define IET_SENSE_BUF_SIZE 18
Index: kernel/file-io.c
===================================================================
--- kernel/file-io.c (revision 339)
+++ kernel/file-io.c (working copy)
@@ -232,7 +232,7 @@ static int fileio_attach(struct iet_volu
}
if (!lu->blk_shift)
- lu->blk_shift = ilog2(IET_DEF_BLOCK_SIZE);
+ lu->blk_shift = blksize_bits(IET_DEF_BLOCK_SIZE);
lu->blk_cnt = inode->i_size >> lu->blk_shift;
Index: kernel/compat.h
===================================================================
--- kernel/compat.h (revision 0)
+++ kernel/compat.h (revision 0)
@@ -0,0 +1,30 @@
+/*
+ * Kernel compatibility routines
+ *
+ * Copyright (C) 2008 Ross Walker <rswwalker at gmail dot com>
+ *
+ * Released under the terms of the GNU GPL v2.0.
+ */
+
+#ifndef __IET_COMPAT_H__
+#define __IET_COMPAT_H__
+
+#include <linux/version.h>
+
+#ifndef DECLARE_COMPLETION_ONSTACK
+#define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
+#endif
+
+#ifndef is_power_of_2
+#define is_power_of_2(n) (n != 0 && ((n & (n - 1)) == 0))
+#endif
+
+#ifndef log2
+#define log2(n) ((sizeof(n) <= 4) ? (fls(n) - 1) : (fls64(n) - 1))
+#endif
+
+#ifndef roundup_pow_of_two
+#define roundup_pow_of_two(n) (1UL << fls_long(n - 1))
+#endif
+
+#endif /* __IET_COMPAT_H__ */
Index: patches/compat-2.6.14-2.6.18.patch
===================================================================
--- patches/compat-2.6.14-2.6.18.patch (revision 339)
+++ patches/compat-2.6.14-2.6.18.patch (working copy)
@@ -2,17 +2,6 @@ Index: kernel/iscsi.h
===================================================================
--- 1/kernel/iscsi.h (revision 105)
+++ 2/kernel/iscsi.h (working copy)
-@@ -20,6 +20,10 @@
- #include "iscsi_hdr.h"
- #include "iet_u.h"
-
-+#ifndef DECLARE_COMPLETION_ONSTACK
-+# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
-+#endif
-+
- #define IET_SENSE_BUF_SIZE 18
-
- struct iscsi_sess_param {
@@ -261,8 +261,8 @@ struct iscsi_conn {
u32 write_offset;
int write_state;
______________________________________________________________________
This e-mail, and any attachments thereto, is intended only for use by
the addressee(s) named herein and may contain legally privileged
and/or confidential information. If you are not the intended recipient
of this e-mail, you are hereby notified that any dissemination,
distribution or copying of this e-mail, and any attachments thereto,
is strictly prohibited. If you have received this e-mail in error,
please immediately notify the sender and permanently delete the
original and any copy or printout thereof.
|