mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage
@ 2011-07-26  7:35 Nicholas A. Bellinger
  2011-07-26  7:35 ` [PATCH-v2 2/2] target: Convert to DIV_ROUND_UP_SECTOR_T usage for sectors / dev_max_sectors Nicholas A. Bellinger
  2011-07-26  8:35 ` [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Nicholas A. Bellinger
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2011-07-26  7:35 UTC (permalink / raw)
  To: target-devel, linux-scsi, linux-kernel
  Cc: Christoph Hellwig, Andy Grover, Hannes Reinecke, Roland Dreier,
	James Bottomley, Andrew Morton, Linus Torvalds,
	Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

Add new DIV_ROUND_UP_SECTOR_T macro usage for 32-bit architectures requiring
a new DIV_ROUND_UP_ULL, and existing 64-bit usage with DIV_ROUND_UP.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 include/linux/kernel.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 953352a..e81b647 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -56,6 +56,14 @@
 
 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#define DIV_ROUND_UP_ULL(ll,d) \
+	({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; })
+
+#if BITS_PER_LONG == 32
+# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d)
+#else
+# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP(ll,d)
+#endif
 
 /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */
 #define roundup(x, y) (					\
-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH-v2 2/2] target: Convert to DIV_ROUND_UP_SECTOR_T usage for sectors / dev_max_sectors
  2011-07-26  7:35 [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Nicholas A. Bellinger
@ 2011-07-26  7:35 ` Nicholas A. Bellinger
  2011-07-26  8:35 ` [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Nicholas A. Bellinger
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2011-07-26  7:35 UTC (permalink / raw)
  To: target-devel, linux-scsi, linux-kernel
  Cc: Christoph Hellwig, Andy Grover, Hannes Reinecke, Roland Dreier,
	James Bottomley, Andrew Morton, Linus Torvalds,
	Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch adds the new macro usage of include/linux/kernel.h:DIV_ROUND_UP_SECTOR_T
usage to use the new DIV_ROUND_UP_ULL() usage for 32-bit architectures with
the unsigned long long sector_t division in transport_allocate_data_tasks() usage
for target_core_mod v4.1

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_transport.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index a244c90..301d5a0 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -4054,17 +4054,16 @@ static int transport_allocate_data_tasks(
 	struct se_task *task;
 	struct se_device *dev = cmd->se_dev;
 	unsigned long flags;
-	sector_t sectors;
 	int task_count, i, ret;
-	sector_t dev_max_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors;
+	sector_t sectors, dev_max_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors;
 	u32 sector_size = dev->se_sub_dev->se_dev_attrib.block_size;
 	struct scatterlist *sg;
 	struct scatterlist *cmd_sg;
 
 	WARN_ON(cmd->data_length % sector_size);
 	sectors = DIV_ROUND_UP(cmd->data_length, sector_size);
-	task_count = DIV_ROUND_UP(sectors, dev_max_sectors);
-
+	task_count = DIV_ROUND_UP_SECTOR_T(sectors, dev_max_sectors);
+	
 	cmd_sg = sgl;
 	for (i = 0; i < task_count; i++) {
 		unsigned int task_size;
-- 
1.7.2.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage
  2011-07-26  7:35 [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Nicholas A. Bellinger
  2011-07-26  7:35 ` [PATCH-v2 2/2] target: Convert to DIV_ROUND_UP_SECTOR_T usage for sectors / dev_max_sectors Nicholas A. Bellinger
@ 2011-07-26  8:35 ` Nicholas A. Bellinger
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas A. Bellinger @ 2011-07-26  8:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-scsi, linux-kernel, Christoph Hellwig, Andy Grover,
	Hannes Reinecke, Roland Dreier, James Bottomley, Andrew Morton,
	Linus Torvalds, target-devel

On Tue, 2011-07-26 at 07:35 +0000, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> Add new DIV_ROUND_UP_SECTOR_T macro usage for 32-bit architectures requiring
> a new DIV_ROUND_UP_ULL, and existing 64-bit usage with DIV_ROUND_UP.
> 
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
> ---
>  include/linux/kernel.h |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 953352a..e81b647 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -56,6 +56,14 @@
>  
>  #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
>  #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> +#define DIV_ROUND_UP_ULL(ll,d) \
> +	({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; })
> +
> +#if BITS_PER_LONG == 32
> +# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d)
> +#else
> +# define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP(ll,d)
> +#endif
>  

Hi Andrew,

Is CONFIG_LBDAF=n usage going to have problems with the above..?  

Things are looking as expected AFAICT with some quick tests with
CONFIG_LBDAF=y on i386, but still need to verify the CONFIG_LBDAF=n on
32-bit as well.  Any more comments here are appercitated.

Thank you,

--nab




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-26  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26  7:35 [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Nicholas A. Bellinger
2011-07-26  7:35 ` [PATCH-v2 2/2] target: Convert to DIV_ROUND_UP_SECTOR_T usage for sectors / dev_max_sectors Nicholas A. Bellinger
2011-07-26  8:35 ` [PATCH-v2 1/2] kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®