fuse_vnops.c (242727) | fuse_vnops.c (248084) |
---|---|
1/* 2 * Copyright (c) 2007-2009 Google Inc. and Amit Singh 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * --- 40 unchanged lines hidden (view full) --- 49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 * SUCH DAMAGE. 54 */ 55 56#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2007-2009 Google Inc. and Amit Singh 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * --- 40 unchanged lines hidden (view full) --- 49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 53 * SUCH DAMAGE. 54 */ 55 56#include <sys/cdefs.h> |
57__FBSDID("$FreeBSD: head/sys/fs/fuse/fuse_vnops.c 242727 2012-11-08 00:32:49Z attilio $"); | 57__FBSDID("$FreeBSD: head/sys/fs/fuse/fuse_vnops.c 248084 2013-03-09 02:32:23Z attilio $"); |
58 59#include <sys/types.h> 60#include <sys/module.h> 61#include <sys/systm.h> 62#include <sys/errno.h> 63#include <sys/param.h> 64#include <sys/kernel.h> 65#include <sys/conf.h> 66#include <sys/uio.h> 67#include <sys/malloc.h> 68#include <sys/queue.h> 69#include <sys/lock.h> | 58 59#include <sys/types.h> 60#include <sys/module.h> 61#include <sys/systm.h> 62#include <sys/errno.h> 63#include <sys/param.h> 64#include <sys/kernel.h> 65#include <sys/conf.h> 66#include <sys/uio.h> 67#include <sys/malloc.h> 68#include <sys/queue.h> 69#include <sys/lock.h> |
70#include <sys/mutex.h> | 70#include <sys/rwlock.h> |
71#include <sys/sx.h> 72#include <sys/proc.h> 73#include <sys/mount.h> 74#include <sys/vnode.h> 75#include <sys/namei.h> 76#include <sys/stat.h> 77#include <sys/unistd.h> 78#include <sys/filedesc.h> --- 1674 unchanged lines hidden (view full) --- 1753 npages = btoc(count); 1754 1755 /* 1756 * If the requested page is partially valid, just return it and 1757 * allow the pager to zero-out the blanks. Partially valid pages 1758 * can only occur at the file EOF. 1759 */ 1760 | 71#include <sys/sx.h> 72#include <sys/proc.h> 73#include <sys/mount.h> 74#include <sys/vnode.h> 75#include <sys/namei.h> 76#include <sys/stat.h> 77#include <sys/unistd.h> 78#include <sys/filedesc.h> --- 1674 unchanged lines hidden (view full) --- 1753 npages = btoc(count); 1754 1755 /* 1756 * If the requested page is partially valid, just return it and 1757 * allow the pager to zero-out the blanks. Partially valid pages 1758 * can only occur at the file EOF. 1759 */ 1760 |
1761 VM_OBJECT_LOCK(vp->v_object); | 1761 VM_OBJECT_WLOCK(vp->v_object); |
1762 fuse_vm_page_lock_queues(); 1763 if (pages[ap->a_reqpage]->valid != 0) { 1764 for (i = 0; i < npages; ++i) { 1765 if (i != ap->a_reqpage) { 1766 fuse_vm_page_lock(pages[i]); 1767 vm_page_free(pages[i]); 1768 fuse_vm_page_unlock(pages[i]); 1769 } 1770 } 1771 fuse_vm_page_unlock_queues(); | 1762 fuse_vm_page_lock_queues(); 1763 if (pages[ap->a_reqpage]->valid != 0) { 1764 for (i = 0; i < npages; ++i) { 1765 if (i != ap->a_reqpage) { 1766 fuse_vm_page_lock(pages[i]); 1767 vm_page_free(pages[i]); 1768 fuse_vm_page_unlock(pages[i]); 1769 } 1770 } 1771 fuse_vm_page_unlock_queues(); |
1772 VM_OBJECT_UNLOCK(vp->v_object); | 1772 VM_OBJECT_WUNLOCK(vp->v_object); |
1773 return 0; 1774 } 1775 fuse_vm_page_unlock_queues(); | 1773 return 0; 1774 } 1775 fuse_vm_page_unlock_queues(); |
1776 VM_OBJECT_UNLOCK(vp->v_object); | 1776 VM_OBJECT_WUNLOCK(vp->v_object); |
1777 1778 /* 1779 * We use only the kva address for the buffer, but this is extremely 1780 * convienient and fast. 1781 */ 1782 bp = getpbuf(&fuse_pbuf_freecnt); 1783 1784 kva = (vm_offset_t)bp->b_data; --- 13 unchanged lines hidden (view full) --- 1798 1799 error = fuse_io_dispatch(vp, &uio, IO_DIRECT, cred); 1800 pmap_qremove(kva, npages); 1801 1802 relpbuf(bp, &fuse_pbuf_freecnt); 1803 1804 if (error && (uio.uio_resid == count)) { 1805 FS_DEBUG("error %d\n", error); | 1777 1778 /* 1779 * We use only the kva address for the buffer, but this is extremely 1780 * convienient and fast. 1781 */ 1782 bp = getpbuf(&fuse_pbuf_freecnt); 1783 1784 kva = (vm_offset_t)bp->b_data; --- 13 unchanged lines hidden (view full) --- 1798 1799 error = fuse_io_dispatch(vp, &uio, IO_DIRECT, cred); 1800 pmap_qremove(kva, npages); 1801 1802 relpbuf(bp, &fuse_pbuf_freecnt); 1803 1804 if (error && (uio.uio_resid == count)) { 1805 FS_DEBUG("error %d\n", error); |
1806 VM_OBJECT_LOCK(vp->v_object); | 1806 VM_OBJECT_WLOCK(vp->v_object); |
1807 fuse_vm_page_lock_queues(); 1808 for (i = 0; i < npages; ++i) { 1809 if (i != ap->a_reqpage) { 1810 fuse_vm_page_lock(pages[i]); 1811 vm_page_free(pages[i]); 1812 fuse_vm_page_unlock(pages[i]); 1813 } 1814 } 1815 fuse_vm_page_unlock_queues(); | 1807 fuse_vm_page_lock_queues(); 1808 for (i = 0; i < npages; ++i) { 1809 if (i != ap->a_reqpage) { 1810 fuse_vm_page_lock(pages[i]); 1811 vm_page_free(pages[i]); 1812 fuse_vm_page_unlock(pages[i]); 1813 } 1814 } 1815 fuse_vm_page_unlock_queues(); |
1816 VM_OBJECT_UNLOCK(vp->v_object); | 1816 VM_OBJECT_WUNLOCK(vp->v_object); |
1817 return VM_PAGER_ERROR; 1818 } 1819 /* 1820 * Calculate the number of bytes read and validate only that number 1821 * of bytes. Note that due to pending writes, size may be 0. This 1822 * does not mean that the remaining data is invalid! 1823 */ 1824 1825 size = count - uio.uio_resid; | 1817 return VM_PAGER_ERROR; 1818 } 1819 /* 1820 * Calculate the number of bytes read and validate only that number 1821 * of bytes. Note that due to pending writes, size may be 0. This 1822 * does not mean that the remaining data is invalid! 1823 */ 1824 1825 size = count - uio.uio_resid; |
1826 VM_OBJECT_LOCK(vp->v_object); | 1826 VM_OBJECT_WLOCK(vp->v_object); |
1827 fuse_vm_page_lock_queues(); 1828 for (i = 0, toff = 0; i < npages; i++, toff = nextoff) { 1829 vm_page_t m; 1830 1831 nextoff = toff + PAGE_SIZE; 1832 m = pages[i]; 1833 1834 if (nextoff <= size) { --- 46 unchanged lines hidden (view full) --- 1881 } else { 1882 fuse_vm_page_lock(m); 1883 vm_page_free(m); 1884 fuse_vm_page_unlock(m); 1885 } 1886 } 1887 } 1888 fuse_vm_page_unlock_queues(); | 1827 fuse_vm_page_lock_queues(); 1828 for (i = 0, toff = 0; i < npages; i++, toff = nextoff) { 1829 vm_page_t m; 1830 1831 nextoff = toff + PAGE_SIZE; 1832 m = pages[i]; 1833 1834 if (nextoff <= size) { --- 46 unchanged lines hidden (view full) --- 1881 } else { 1882 fuse_vm_page_lock(m); 1883 vm_page_free(m); 1884 fuse_vm_page_unlock(m); 1885 } 1886 } 1887 } 1888 fuse_vm_page_unlock_queues(); |
1889 VM_OBJECT_UNLOCK(vp->v_object); | 1889 VM_OBJECT_WUNLOCK(vp->v_object); |
1890 return 0; 1891} 1892 1893/* 1894 struct vnop_putpages_args { 1895 struct vnode *a_vp; 1896 vm_page_t *a_m; 1897 int a_count; --- 72 unchanged lines hidden (view full) --- 1970 pmap_qremove(kva, npages); 1971 relpbuf(bp, &fuse_pbuf_freecnt); 1972 1973 if (!error) { 1974 int nwritten = round_page(count - uio.uio_resid) / PAGE_SIZE; 1975 1976 for (i = 0; i < nwritten; i++) { 1977 rtvals[i] = VM_PAGER_OK; | 1890 return 0; 1891} 1892 1893/* 1894 struct vnop_putpages_args { 1895 struct vnode *a_vp; 1896 vm_page_t *a_m; 1897 int a_count; --- 72 unchanged lines hidden (view full) --- 1970 pmap_qremove(kva, npages); 1971 relpbuf(bp, &fuse_pbuf_freecnt); 1972 1973 if (!error) { 1974 int nwritten = round_page(count - uio.uio_resid) / PAGE_SIZE; 1975 1976 for (i = 0; i < nwritten; i++) { 1977 rtvals[i] = VM_PAGER_OK; |
1978 VM_OBJECT_LOCK(pages[i]->object); | 1978 VM_OBJECT_WLOCK(pages[i]->object); |
1979 vm_page_undirty(pages[i]); | 1979 vm_page_undirty(pages[i]); |
1980 VM_OBJECT_UNLOCK(pages[i]->object); | 1980 VM_OBJECT_WUNLOCK(pages[i]->object); |
1981 } 1982 } 1983 return rtvals[0]; 1984} 1985 1986/* 1987 struct vnop_print_args { 1988 struct vnode *a_vp; --- 14 unchanged lines hidden --- | 1981 } 1982 } 1983 return rtvals[0]; 1984} 1985 1986/* 1987 struct vnop_print_args { 1988 struct vnode *a_vp; --- 14 unchanged lines hidden --- |