WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] tools, bsd: complete implementation of di

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] tools, bsd: complete implementation of discard_file_cache
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Dec 2010 05:35:00 -0800
Delivery-date: Thu, 23 Dec 2010 05:46:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Christoph Egger <Christoph.Egger@xxxxxxx>
# Date 1292523716 0
# Node ID 3bb6574e6707a8f6007e97c7d0933b6534d10348
# Parent  f1b435507f343a480e61c926a1b72a4889175ce7
tools, bsd: complete implementation of discard_file_cache

attached patch completes discard_file_cache() for NetBSD.

Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxc/xc_netbsd.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletion(-)

diff -r f1b435507f34 -r 3bb6574e6707 tools/libxc/xc_netbsd.c
--- a/tools/libxc/xc_netbsd.c   Thu Dec 16 18:04:08 2010 +0000
+++ b/tools/libxc/xc_netbsd.c   Thu Dec 16 18:21:56 2010 +0000
@@ -280,11 +280,36 @@ int xc_evtchn_unmask(int xce_handle, evt
 /* Optionally flush file to disk and discard page cache */
 void discard_file_cache(xc_interface *xch, int fd, int flush) 
 {
+    off_t cur = 0;
+    int saved_errno = errno;
 
     if ( flush && (fsync(fd) < 0) )
     {
         /*PERROR("Failed to flush file: %s", strerror(errno));*/
-    }
+        goto out;
+    }
+
+    /*
+     * Calculate last page boundry of amount written so far
+     * unless we are flushing in which case entire cache
+     * is discarded.
+     */
+    if ( !flush )
+    {
+        if ( ( cur = lseek(fd, 0, SEEK_CUR)) == (off_t)-1 )
+            cur = 0;
+        cur &= ~(PAGE_SIZE - 1);
+    }
+
+    /* Discard from the buffer cache. */
+    if ( posix_fadvise(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 )
+    {
+        /*PERROR("Failed to discard cache: %s", strerror(errno));*/
+        goto out;
+    }
+
+ out:
+    errno = saved_errno;
 }
 
 grant_entry_v1_t *xc_gnttab_map_table_v1(

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] tools, bsd: complete implementation of discard_file_cache, Xen patchbot-unstable <=