LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: Mark Tuttle <marklinux@tuttlelabs.com>,
	Bart Van Assche <bart.vanassche@gmail.com>,
	Jens Axboe <jens.axboe@oracle.com>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Mike Christie <michaelc@cs.wisc.edu>,
	Ming Zhang <mingz@ele.uri.edu>, Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: struct page vs page_link
Date: Tue, 12 Feb 2008 20:20:46 -0800	[thread overview]
Message-ID: <1202876446.19945.18.camel@haakon2.linux-iscsi.org> (raw)
In-Reply-To: <9803672c0802101126u4dd171dai48ea3d21fa84091e@mail.gmail.com>

Hi Mark,

After Bark posted an BUG() when CONFIG_DEBUG_SG was used with
LIO-Target, I add the proper usage of sg_table_init() and sg_mark_end()
in the LIO-Target SE.  Please update your case (if you are not doing it
already).  Here are my new changes for those who are still updating
drivers to use the new include/linux/scatterlist.h API.

--nab 

Index: include/iscsi_linux_defs.h
===================================================================
--- include/iscsi_linux_defs.h  (revision 214)
+++ include/iscsi_linux_defs.h  (revision 215)
@@ -49,11 +49,14 @@
  * code, and use inline functions for legacy operation. 
  */
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+# define SET_SG_TABLE(sg, cnt)         sg_init_table((struct scatterlist *)&sg[0], cnt);       \
+                                               sg_mark_end((struct scatterlist *)&sg[cnt - 1]);
 # define GET_ADDR_SG(sg)               sg_virt(sg)
 # define GET_PAGE_SG(sg)               sg_page(sg)
 # define SET_PAGE_SG(sg, page)         sg_assign_page(sg, page)
 #else
 #include <linux/scatterlist.h>
+#define SET_SG_TABLE(sg, cnt)  
 static inline void *GET_ADDR_SG(struct scatterlist *sg)
 {
        return(page_address(sg->page) + sg->offset);

As you can see, the pre 2.6.24 case expands to a nop.

In my case with LIO-Target and generating SC arrays going to the default
path (which is common for PSCSI, IBLOCK, FILE, and RAMDISK_MCP) where
se_mem_t list head struct page is mapped to struct page-link in the
contigious struct scatterlist arrays.

In the iscsi_target_transport.c:transport_calc_sg_num() and scatterlist
allocation for RAMDISK_DR and RAMDISK_MCP, I added the usage of
SET_SG_TABLE right after the array of struct scatterlist right after the
struct scatterlist array has been allocated and memset.

Index: target/iscsi_target_rd.c
===================================================================
--- target/iscsi_target_rd.c    (revision 215)
+++ target/iscsi_target_rd.c    (revision 217)
@@ -209,6 +209,8 @@
                }
                memset(sg, 0, sg_per_table * sizeof(struct scatterlist));
 
+               SET_SG_TABLE(sg, sg_per_table);
+
                sg_table[i].sg_table = sg;
                sg_table[i].rd_sg_count = sg_per_table;
                sg_table[i].page_start_offset = page_offset;
Index: target/iscsi_target_transport.c
===================================================================
--- target/iscsi_target_transport.c     (revision 215)
+++ target/iscsi_target_transport.c     (revision 217)
@@ -5096,6 +5096,8 @@
        }
        memset(task->task_buf, 0, task->task_sg_num * sizeof(struct scatterlist));
 
+       SET_SG_TABLE(task->task_buf, task->task_sg_num);
+
        DEBUG_SC("Successfully allocated task->task_sg_num: %u\n", task->task_sg_num);
        
        return(task->task_sg_num);

On Sun, 2008-02-10 at 14:26 -0500, Mark Tuttle wrote:
> Thanks for that information, I analysed your code to get a better
> understanding of exactly what was going on and was able to
> successfully patch what I needed to.
> 
> http://www.tuttleresearch.com/80211patch.html
> 
> Much appreciated,
> Mark Tuttle
> 
> On 2/9/08, Nicholas A. Bellinger <nab@linux-iscsi.org> wrote:
> > On Sat, 2008-02-09 at 01:28 -0500, Mark Tuttle wrote:
> > > Regarding:
> > > commit 18dabf473e15850c0dbc8ff13ac1e2806d542c15
> > >
> > > This actually breaks the 802.11 subsystem (http://80211.sf.net) which
> > > relies on the page struct. (ieee80211_crypt_wep.c, line 190) Can
> > > anyone suggest an alternative kernel function or method? As of 2.6.24,
> > > the 802.11 subsystem cannot compile.
> > >
> >
> > Greetings Mark,
> >
> > I have been updating the LIO-Target codebase to 2.6.24 recently, and
> > posted some information about what I ended up doing for struct
> > scatterlist->page changing to scatterlist->page_link and
> > include/linux/scatterlist.h
> >
> > http://lkml.org/lkml/2008/2/4/111
> >
> > Hope this helps,
> >
> > --nab
> >
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


      reply	other threads:[~2008-02-13  4:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-09  6:28 Mark Tuttle
2008-02-09 12:06 ` Nicholas A. Bellinger
2008-02-10 19:26   ` Mark Tuttle
2008-02-13  4:20     ` Nicholas A. Bellinger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1202876446.19945.18.camel@haakon2.linux-iscsi.org \
    --to=nab@linux-iscsi.org \
    --cc=akpm@osdl.org \
    --cc=bart.vanassche@gmail.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marklinux@tuttlelabs.com \
    --cc=michaelc@cs.wisc.edu \
    --cc=mingz@ele.uri.edu \
    --subject='Re: struct page vs page_link' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).