From patchwork Tue Jun 14 21:03:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 880132 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5EL25Mi011700 for ; Tue, 14 Jun 2011 21:03:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753956Ab1FNVDc (ORCPT ); Tue, 14 Jun 2011 17:03:32 -0400 Received: from daytona.panasas.com ([67.152.220.89]:36604 "EHLO daytona.panasas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753928Ab1FNVDc (ORCPT ); Tue, 14 Jun 2011 17:03:32 -0400 Received: from yafyuf.citi.umich.edu ([172.17.33.117]) by daytona.panasas.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 14 Jun 2011 17:03:31 -0400 From: Boaz Harrosh To: Benny Halevy , open-osd , NFS list Subject: [PATCH 6/8] pnfsd-exofs: get_device_info implementation. Date: Tue, 14 Jun 2011 17:03:31 -0400 Message-Id: <1308085411-12630-1-git-send-email-bharrosh@panasas.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <4DF7CA2F.7030407@panasas.com> References: <4DF7CA2F.7030407@panasas.com> X-OriginalArrivalTime: 14 Jun 2011 21:03:31.0459 (UTC) FILETIME=[841A5D30:01CC2AD6] Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 14 Jun 2011 21:03:33 +0000 (UTC) Implement a .get_device_info operation from the pnfs_export_operations. Retrieve to system_id and osdname for the requested devices. TODO: Return also UNC hints for the device login information. Signed-off-by: Boaz Harrosh --- fs/exofs/export.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/fs/exofs/export.c b/fs/exofs/export.c index 0a068b7..23c1666 100644 --- a/fs/exofs/export.c +++ b/fs/exofs/export.c @@ -185,11 +185,65 @@ static int exofs_layout_return( return 0; } +int exofs_get_device_info(struct super_block *sb, struct exp_xdr_stream *xdr, + u32 layout_type, + const struct nfsd4_pnfs_deviceid *devid) +{ + struct exofs_sb_info *sbi = sb->s_fs_info; + struct pnfs_osd_deviceaddr devaddr; + const struct osd_dev_info *odi; + u64 devno = devid->devid; + __be32 *start; + int err; + + memset(&devaddr, 0, sizeof(devaddr)); + + if (unlikely(devno >= sbi->layout.s_numdevs)) { + EXOFS_DBGMSG("Error: Device((%llx,%llx) does not exist\n", + devid->sbid, devno); + return -ENODEV; + } + + odi = osduld_device_info(sbi->layout.s_ods[devno]); + + devaddr.oda_systemid.len = odi->systemid_len; + devaddr.oda_systemid.data = (void *)odi->systemid; /* !const cast */ + + devaddr.oda_osdname.len = odi->osdname_len ; + devaddr.oda_osdname.data = (void *)odi->osdname;/* !const cast */ + + /* skip opaque size, will be filled-in later */ + start = exp_xdr_reserve_qwords(xdr, 1); + if (!start) { + err = -ETOOSMALL; + goto err; + } + + err = pnfs_osd_xdr_encode_deviceaddr(xdr, &devaddr); + if (err) { + err = -ETOOSMALL; + goto err; + } + + exp_xdr_encode_opaque_len(start, xdr->p); + + EXOFS_DBGMSG("xdr_bytes=%Zu devid=(%llx,%llx) osdname-%s\n", + exp_xdr_qbytes(xdr->p - start), devid->sbid, devno, + odi->osdname); + return 0; + +err: + EXOFS_DBGMSG("Error: err=%d at_byte=%zu\n", + err, exp_xdr_qbytes(xdr->p - start)); + return err; +} + struct pnfs_export_operations exofs_pnfs_ops = { .layout_type = exofs_layout_type, .layout_get = exofs_layout_get, .layout_commit = exofs_layout_commit, .layout_return = exofs_layout_return, + .get_device_info = exofs_get_device_info, }; void exofs_init_export(struct super_block *sb)