direct-io.hg

changeset 7953:976e53674e84

Merged.
author emellor@leeni.uk.xensource.com
date Mon Nov 21 18:33:27 2005 +0100 (2005-11-21)
parents fbd3f3cb6f65 52020caa244f
children eaec9512f618
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Nov 21 18:33:17 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Nov 21 18:33:27 2005 +0100
     1.3 @@ -99,27 +99,6 @@ static unsigned long alloc_mfn(void)
     1.4  	return mfn;
     1.5  }
     1.6  
     1.7 -static void free_mfn(unsigned long mfn)
     1.8 -{
     1.9 -	unsigned long flags;
    1.10 -	struct xen_memory_reservation reservation = {
    1.11 -		.extent_start = &mfn,
    1.12 -		.nr_extents   = 1,
    1.13 -		.extent_order = 0,
    1.14 -		.domid        = DOMID_SELF
    1.15 -	};
    1.16 -	spin_lock_irqsave(&mfn_lock, flags);
    1.17 -	if ( alloc_index != MAX_MFN_ALLOC )
    1.18 -		mfn_list[alloc_index++] = mfn;
    1.19 -	else {
    1.20 -		int ret;
    1.21 -		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
    1.22 -					    &reservation);
    1.23 -		BUG_ON(ret != 1);
    1.24 -	}
    1.25 -	spin_unlock_irqrestore(&mfn_lock, flags);
    1.26 -}
    1.27 -
    1.28  static inline void maybe_schedule_tx_action(void)
    1.29  {
    1.30  	smp_mb();
    1.31 @@ -306,14 +285,18 @@ static void net_rx_action(unsigned long 
    1.32  		netif->stats.tx_packets++;
    1.33  
    1.34  		/* The update_va_mapping() must not fail. */
    1.35 -		BUG_ON(mcl[0].result != 0);
    1.36 +		BUG_ON(mcl->result != 0);
    1.37  
    1.38  		/* Check the reassignment error code. */
    1.39  		status = NETIF_RSP_OKAY;
    1.40  		if (gop->status != 0) { 
    1.41  			DPRINTK("Bad status %d from grant transfer to DOM%u\n",
    1.42  				gop->status, netif->domid);
    1.43 -			free_mfn(old_mfn);
    1.44 +			/*
    1.45 +                         * Page no longer belongs to us unless GNTST_bad_page,
    1.46 +                         * but that should be a fatal error anyway.
    1.47 +                         */
    1.48 +			BUG_ON(gop->status == GNTST_bad_page);
    1.49  			status = NETIF_RSP_ERROR; 
    1.50  		}
    1.51  		irq = netif->irq;
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Nov 21 18:33:17 2005 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Nov 21 18:33:27 2005 +0100
     2.3 @@ -789,7 +789,7 @@ class XendDomainInfo:
     2.4                          log.debug(
     2.5                              "Scheduling refreshShutdown on domain %d in %ds.",
     2.6                              self.domid, timeout)
     2.7 -                        scheduler.later(timeout, self.refreshShutdown)
     2.8 +                        threading.Timer(timeout, self.refreshShutdown).start()
     2.9          finally:
    2.10              self.refresh_shutdown_lock.release()
    2.11  
    2.12 @@ -830,7 +830,7 @@ class XendDomainInfo:
    2.13          try:
    2.14              corefile = "/var/xen/dump/%s.%s.core" % (self.info['name'],
    2.15                                                       self.domid)
    2.16 -            xc.domain_dumpcore(dom = self.domid, corefile = corefile)
    2.17 +            xc.domain_dumpcore(self.domid, corefile)
    2.18  
    2.19          except:
    2.20              log.exception("XendDomainInfo.dumpCore failed: id = %s name = %s",
    2.21 @@ -1106,7 +1106,7 @@ class XendDomainInfo:
    2.22              xc.domain_setcpuweight(self.domid, self.info['cpu_weight'])
    2.23  
    2.24              m = self.image.getDomainMemory(self.info['memory'] * 1024)
    2.25 -            xc.domain_setmaxmem(self.domid, maxmem_kb = m)
    2.26 +            xc.domain_setmaxmem(self.domid, m)
    2.27              xc.domain_memory_increase_reservation(self.domid, m, 0, 0)
    2.28  
    2.29              cpu = self.info['cpu']
    2.30 @@ -1195,7 +1195,7 @@ class XendDomainInfo:
    2.31  
    2.32          try:
    2.33              if self.domid is not None:
    2.34 -                xc.domain_destroy(dom=self.domid)
    2.35 +                xc.domain_destroy(self.domid)
    2.36          except:
    2.37              log.exception("XendDomainInfo.destroy: xc.domain_destroy failed.")
    2.38  
     3.1 --- a/xen/common/grant_table.c	Mon Nov 21 18:33:17 2005 +0100
     3.2 +++ b/xen/common/grant_table.c	Mon Nov 21 18:33:27 2005 +0100
     3.3 @@ -714,26 +714,18 @@ gnttab_transfer(
     3.4          /* Read from caller address space. */
     3.5          if ( unlikely(__copy_from_user(&gop, &uop[i], sizeof(gop))) )
     3.6          {
     3.7 -            /* Caller error: bail immediately. */
     3.8              DPRINTK("gnttab_transfer: error reading req %d/%d\n", i, count);
     3.9 -            return -EFAULT;
    3.10 +            (void)__put_user(GNTST_bad_page, &uop[i].status);
    3.11 +            return -EFAULT; /* This is *very* fatal. */
    3.12          }
    3.13  
    3.14          /* Check the passed page frame for basic validity. */
    3.15          page = &frame_table[gop.mfn];
    3.16          if ( unlikely(!pfn_valid(gop.mfn) || IS_XEN_HEAP_FRAME(page)) )
    3.17          { 
    3.18 -            /* Caller error: bail immediately. */
    3.19              DPRINTK("gnttab_transfer: out-of-range or xen frame %lx\n",
    3.20                      (unsigned long)gop.mfn);
    3.21 -            return -EINVAL;
    3.22 -        }
    3.23 -
    3.24 -        /* Find the target domain. */
    3.25 -        if ( unlikely((e = find_domain_by_id(gop.domid)) == NULL) )
    3.26 -        {
    3.27 -            DPRINTK("gnttab_transfer: can't find domain %d\n", gop.domid);
    3.28 -            (void)__put_user(GNTST_bad_domain, &uop[i].status);
    3.29 +            (void)__put_user(GNTST_bad_page, &uop[i].status);
    3.30              continue;
    3.31          }
    3.32  
    3.33 @@ -752,15 +744,14 @@ gnttab_transfer(
    3.34              x = y;
    3.35              if (unlikely((x & (PGC_count_mask|PGC_allocated)) !=
    3.36                           (1 | PGC_allocated)) || unlikely(_nd != _d)) { 
    3.37 -                /* Caller error: bail immediately. */
    3.38                  DPRINTK("gnttab_transfer: Bad page %p: ed=%p(%u), sd=%p,"
    3.39                         " caf=%08x, taf=%" PRtype_info "\n", 
    3.40                         (void *) page_to_pfn(page),
    3.41                          d, d->domain_id, unpickle_domptr(_nd), x, 
    3.42                          page->u.inuse.type_info);
    3.43                  spin_unlock(&d->page_alloc_lock);
    3.44 -                put_domain(e);
    3.45 -                return -EINVAL;
    3.46 +                (void)__put_user(GNTST_bad_page, &uop[i].status);
    3.47 +                continue;
    3.48              }
    3.49              __asm__ __volatile__(
    3.50                  LOCK_PREFIX "cmpxchg8b %2"
    3.51 @@ -779,6 +770,16 @@ gnttab_transfer(
    3.52  
    3.53          spin_unlock(&d->page_alloc_lock);
    3.54  
    3.55 +        /* Find the target domain. */
    3.56 +        if ( unlikely((e = find_domain_by_id(gop.domid)) == NULL) )
    3.57 +        {
    3.58 +            DPRINTK("gnttab_transfer: can't find domain %d\n", gop.domid);
    3.59 +            (void)__put_user(GNTST_bad_domain, &uop[i].status);
    3.60 +            page->count_info &= ~(PGC_count_mask|PGC_allocated);
    3.61 +            free_domheap_page(page);
    3.62 +            continue;
    3.63 +        }
    3.64 +
    3.65          spin_lock(&e->page_alloc_lock);
    3.66  
    3.67          /*
    3.68 @@ -797,6 +798,8 @@ gnttab_transfer(
    3.69              spin_unlock(&e->page_alloc_lock);
    3.70              put_domain(e);
    3.71              (void)__put_user(GNTST_general_error, &uop[i].status);
    3.72 +            page->count_info &= ~(PGC_count_mask|PGC_allocated);
    3.73 +            free_domheap_page(page);
    3.74              continue;
    3.75          }
    3.76  
     4.1 --- a/xen/common/page_alloc.c	Mon Nov 21 18:33:17 2005 +0100
     4.2 +++ b/xen/common/page_alloc.c	Mon Nov 21 18:33:27 2005 +0100
     4.3 @@ -645,7 +645,9 @@ void free_domheap_pages(struct pfn_info 
     4.4      }
     4.5      else
     4.6      {
     4.7 -        /* Freeing an anonymous domain-heap page. */
     4.8 +        /* Freeing anonymous domain-heap pages. */
     4.9 +        for ( i = 0; i < (1 << order); i++ )
    4.10 +            pg[i].u.free.cpumask = CPU_MASK_NONE;
    4.11          free_heap_pages(pfn_dom_zone_type(page_to_pfn(pg)), pg, order);
    4.12          drop_dom_ref = 0;
    4.13      }
     5.1 --- a/xen/include/public/grant_table.h	Mon Nov 21 18:33:17 2005 +0100
     5.2 +++ b/xen/include/public/grant_table.h	Mon Nov 21 18:33:27 2005 +0100
     5.3 @@ -215,9 +215,12 @@ typedef struct gnttab_dump_table {
     5.4  } gnttab_dump_table_t;
     5.5  
     5.6  /*
     5.7 - * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain.  The
     5.8 - * foreign domain has previously registered the details of the transfer.
     5.9 - * These can be identified from <handle>, a grant reference.
    5.10 + * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
    5.11 + * foreign domain has previously registered its interest in the transfer via
    5.12 + * <domid, ref>.
    5.13 + * 
    5.14 + * Note that, even if the transfer fails, the specified page no longer belongs
    5.15 + * to the calling domain *unless* the error is GNTST_bad_page.
    5.16   */
    5.17  #define GNTTABOP_transfer                4
    5.18  typedef struct {
    5.19 @@ -269,6 +272,7 @@ typedef struct {
    5.20  #define GNTST_bad_dev_addr     (-6) /* Inappropriate device address to unmap.*/
    5.21  #define GNTST_no_device_space  (-7) /* Out of space in I/O MMU.              */
    5.22  #define GNTST_permission_denied (-8) /* Not enough privilege for operation.  */
    5.23 +#define GNTST_bad_page         (-9) /* Specified page was invalid for op.    */
    5.24  
    5.25  #define GNTTABOP_error_msgs {                   \
    5.26      "okay",                                     \