Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754212AbdCMWaN (ORCPT ); Mon, 13 Mar 2017 18:30:13 -0400 Received: from mail.kernel.org ([198.145.29.136]:35856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753834AbdCMWaG (ORCPT ); Mon, 13 Mar 2017 18:30:06 -0400 Date: Mon, 13 Mar 2017 15:28:47 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: Boris Ostrovsky cc: Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Stefano Stabellini , jgross@suse.com, Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , v9fs-developer@lists.sourceforge.net Subject: Re: [PATCH v2 4/7] xen/9pfs: connect to the backend In-Reply-To: <087e9f1a-824a-02af-6822-f74f906d3356@oracle.com> Message-ID: References: <1489017502-18617-1-git-send-email-sstabellini@kernel.org> <1489017502-18617-4-git-send-email-sstabellini@kernel.org> <087e9f1a-824a-02af-6822-f74f906d3356@oracle.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1439 Lines: 43 On Thu, 9 Mar 2017, Boris Ostrovsky wrote: > > + > > +static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev, > > + struct xen_9pfs_dataring *ring) > > +{ > > + int i; > > + int ret = -ENOMEM; > > + > > + init_waitqueue_head(&ring->wq); > > + spin_lock_init(&ring->lock); > > + INIT_WORK(&ring->work, p9_xen_response); > > + > > + ring->intf = (struct xen_9pfs_data_intf *) get_zeroed_page(GFP_KERNEL | __GFP_ZERO); > > + if (!ring->intf) > > + return ret; > > + ring->ref = gnttab_grant_foreign_access(dev->otherend_id, virt_to_gfn(ring->intf), 0); > > + ring->bytes = (void*)__get_free_pages(GFP_KERNEL | __GFP_ZERO, > > + XEN_9PFS_RING_ORDER - (PAGE_SHIFT - XEN_PAGE_SHIFT)); > > + if (ring->bytes == NULL) > > + goto out; > > + for (i = 0; i < (1 << XEN_9PFS_RING_ORDER); i++) > > + ring->intf->ref[i] = gnttab_grant_foreign_access(dev->otherend_id, virt_to_gfn(ring->bytes) + i, 0); > > You need to handle gnttab_grant_foreign_access() returning an error. For > ring->ref too. > > (and maybe wrap the line above) I'll do > > + ring->ring.in = ring->bytes; > > ring->ring? Maybe 'dataring' for the top-level structure? I changed it to ring->data > BTW, do we really need 'bytes' member? It's always 'ring.in' AFAICT. You > could make it a union with 'ring' (the second 'ring' ;-)) if you want to > keep a pointer to the whole thing as a dedicated name. You are right, I don't need bytes, I'll get rid of it