ia64/linux-2.6.18-xen.hg

changeset 894:4e5cd2fc45a7

linux: fix blkback/blktap2 interaction

blkback's page map code needs to be accessible to both blkback and
blktap2, irrespective of whether either or both are modules. The
most immediate solution is to break it out into a separate, library-
like component that doesn't need building if either of the two
consumers is configured off, and that gets built as a module if both
consumers are modules.

Also fix the dummy implementation of blkback_pagemap_read(), since
using BUG() there doesn't compile.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:33:52 2009 +0100 (2009-06-04)
parents f994bfe9b93b
children 20be7f6d414a
files drivers/xen/Kconfig drivers/xen/blkback/Makefile drivers/xen/blkback/blkback-pagemap.c drivers/xen/blkback/blkback-pagemap.h drivers/xen/blkback/common.h drivers/xen/blktap2/device.c
line diff
     1.1 --- a/drivers/xen/Kconfig	Thu Jun 04 10:32:57 2009 +0100
     1.2 +++ b/drivers/xen/Kconfig	Thu Jun 04 10:33:52 2009 +0100
     1.3 @@ -75,6 +75,11 @@ config XEN_BLKDEV_TAP2
     1.4            as files, in memory, or on other hosts across the network.  This 
     1.5  	  driver can safely coexist with the existing blockback driver.
     1.6  
     1.7 +config XEN_BLKBACK_PAGEMAP
     1.8 +	tristate
     1.9 +	depends on XEN_BLKDEV_BACKEND != n && XEN_BLKDEV_TAP2 != n
    1.10 +	default XEN_BLKDEV_BACKEND || XEN_BLKDEV_TAP2
    1.11 +
    1.12  config XEN_NETDEV_BACKEND
    1.13  	tristate "Network-device backend driver"
    1.14          depends on XEN_BACKEND && NET
     2.1 --- a/drivers/xen/blkback/Makefile	Thu Jun 04 10:32:57 2009 +0100
     2.2 +++ b/drivers/xen/blkback/Makefile	Thu Jun 04 10:33:52 2009 +0100
     2.3 @@ -1,3 +1,4 @@
     2.4  obj-$(CONFIG_XEN_BLKDEV_BACKEND) := blkbk.o
     2.5 +obj-$(CONFIG_XEN_BLKBACK_PAGEMAP) += blkback-pagemap.o
     2.6  
     2.7 -blkbk-y	:= blkback.o xenbus.o interface.o vbd.o blkback-pagemap.o
     2.8 +blkbk-y	:= blkback.o xenbus.o interface.o vbd.o
     3.1 --- a/drivers/xen/blkback/blkback-pagemap.c	Thu Jun 04 10:32:57 2009 +0100
     3.2 +++ b/drivers/xen/blkback/blkback-pagemap.c	Thu Jun 04 10:33:52 2009 +0100
     3.3 @@ -1,4 +1,4 @@
     3.4 -#include "common.h"
     3.5 +#include <linux/module.h>
     3.6  #include "blkback-pagemap.h"
     3.7  
     3.8  static int blkback_pagemap_size;
     3.9 @@ -22,6 +22,7 @@ blkback_pagemap_init(int pages)
    3.10  	blkback_pagemap_size = pages;
    3.11  	return 0;
    3.12  }
    3.13 +EXPORT_SYMBOL_GPL(blkback_pagemap_init);
    3.14  
    3.15  void
    3.16  blkback_pagemap_set(int idx, struct page *page,
    3.17 @@ -46,6 +47,7 @@ blkback_pagemap_set(int idx, struct page
    3.18  	entry->busid = busid;
    3.19  	entry->gref  = gref;
    3.20  }
    3.21 +EXPORT_SYMBOL_GPL(blkback_pagemap_set);
    3.22  
    3.23  void
    3.24  blkback_pagemap_clear(struct page *page)
    3.25 @@ -67,6 +69,7 @@ blkback_pagemap_clear(struct page *page)
    3.26  
    3.27  	memset(entry, 0, sizeof(*entry));
    3.28  }
    3.29 +EXPORT_SYMBOL_GPL(blkback_pagemap_clear);
    3.30  
    3.31  struct blkback_pagemap
    3.32  blkback_pagemap_read(struct page *page)
    3.33 @@ -89,3 +92,5 @@ blkback_pagemap_read(struct page *page)
    3.34  	return *entry;
    3.35  }
    3.36  EXPORT_SYMBOL(blkback_pagemap_read);
    3.37 +
    3.38 +MODULE_LICENSE("Dual BSD/GPL");
     4.1 --- a/drivers/xen/blkback/blkback-pagemap.h	Thu Jun 04 10:32:57 2009 +0100
     4.2 +++ b/drivers/xen/blkback/blkback-pagemap.h	Thu Jun 04 10:33:52 2009 +0100
     4.3 @@ -1,6 +1,7 @@
     4.4  #ifndef _BLKBACK_PAGEMAP_H_
     4.5  #define _BLKBACK_PAGEMAP_H_
     4.6  
     4.7 +#include <linux/mm.h>
     4.8  #include <xen/interface/xen.h>
     4.9  #include <xen/interface/grant_table.h>
    4.10  
    4.11 @@ -12,6 +13,25 @@ struct blkback_pagemap {
    4.12  	grant_ref_t      gref;
    4.13  };
    4.14  
    4.15 +#if defined(CONFIG_XEN_BLKBACK_PAGEMAP) || defined(CONFIG_XEN_BLKBACK_PAGEMAP_MODULE)
    4.16 +
    4.17 +int blkback_pagemap_init(int);
    4.18 +void blkback_pagemap_set(int, struct page *, domid_t, busid_t, grant_ref_t);
    4.19 +void blkback_pagemap_clear(struct page *);
    4.20  struct blkback_pagemap blkback_pagemap_read(struct page *);
    4.21  
    4.22 +#else /* CONFIG_XEN_BLKBACK_PAGEMAP */
    4.23 +
    4.24 +static inline int blkback_pagemap_init(int pages) { return 0; }
    4.25 +static inline void blkback_pagemap_set(int idx, struct page *page, domid_t dom,
    4.26 +				       busid_t bus, grant_ref_t gnt) {}
    4.27 +static inline void blkback_pagemap_clear(struct page *page) {}
    4.28 +static inline struct blkback_pagemap blkback_pagemap_read(struct page *page)
    4.29 +{
    4.30 +	BUG();
    4.31 +	return (struct blkback_pagemap){-1, -1, -1};
    4.32 +}
    4.33 +
    4.34 +#endif /* CONFIG_XEN_BLKBACK_PAGEMAP */
    4.35 +
    4.36  #endif
     5.1 --- a/drivers/xen/blkback/common.h	Thu Jun 04 10:32:57 2009 +0100
     5.2 +++ b/drivers/xen/blkback/common.h	Thu Jun 04 10:33:52 2009 +0100
     5.3 @@ -138,8 +138,4 @@ int blkif_schedule(void *arg);
     5.4  int blkback_barrier(struct xenbus_transaction xbt,
     5.5  		    struct backend_info *be, int state);
     5.6  
     5.7 -int blkback_pagemap_init(int);
     5.8 -void blkback_pagemap_set(int, struct page *, domid_t, busid_t, grant_ref_t);
     5.9 -void blkback_pagemap_clear(struct page *);
    5.10 -
    5.11  #endif /* __BLKIF__BACKEND__COMMON_H__ */
     6.1 --- a/drivers/xen/blktap2/device.c	Thu Jun 04 10:32:57 2009 +0100
     6.2 +++ b/drivers/xen/blktap2/device.c	Thu Jun 04 10:33:52 2009 +0100
     6.3 @@ -13,13 +13,7 @@
     6.4  
     6.5  #include "blktap.h"
     6.6  
     6.7 -#if defined(CONFIG_XEN_BLKDEV_BACKEND) || \
     6.8 -    (defined(CONFIG_XEN_BLKDEV_BACKEND_MODULE) && defined(MODULE))
     6.9  #include "../blkback/blkback-pagemap.h"
    6.10 -#else
    6.11 -struct blkback_pagemap { };
    6.12 -#define blkback_pagemap_read(page) BUG();
    6.13 -#endif
    6.14  
    6.15  #if 0
    6.16  #define DPRINTK_IOCTL(_f, _a...) printk(KERN_ALERT _f, ## _a)