home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / patches / pnfs / p00003_pnfs_nfsproclayoutsupport.patch < prev    next >
Text File  |  2008-01-07  |  10KB  |  241 lines

  1.  
  2. Modify the NFS exported PVFS2 client to support the pNFS file-based layout
  3. driver. The generated file-based layout is derived from the data servers
  4. listed in the proc file system.
  5. pNFS support is achieved by implementing the pNFS export operations
  6. that manage the pNFS data layout information.
  7.  
  8.  
  9. The goal of this patch is to generate a pNFS file layout based on the
  10. I/O servers (data servers) listed in a proc file system variable.  Using
  11. a proc variable allows a sysadmin to select which nodes the pNFS client will
  12. use for I/O.  The data servers listed must be exported PVFS2 clients.
  13.  
  14. When a pNFS client requests a file-based data layout for a file, the exported
  15. PVFS2 client module retrieves the ordered listed of I/O servers from the
  16. /proc system variable.
  17. The PVFS2 client then uses the I/O servers to create a file-based layout and
  18. returns the layout to the nfs server.
  19.  
  20. To use this patch and generate a file-based layout based on the existing PVFS2
  21. I/O servers, the layouttype proc variable must be set to 5.
  22.  
  23. This patch compiles against a version of the 2.6.18.3 linux kernel.
  24.  
  25.  
  26. ---
  27.  
  28.  pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pnfs.c         |  109 +++++++++-
  29.  pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-kernel.h |    3 
  30.  pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-mod.c    |    1 
  31.  pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-pnfs.h   |    1 
  32.  pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-proc.c   |    3 
  33.  pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/super.c        |    4 
  34.  6 files changed, 120 insertions(+), 1 deletion(-)
  35.  
  36. diff -puN src/kernel/linux-2.6/pvfs2-kernel.h~nfsproclayoutsupport src/kernel/linux-2.6/pvfs2-kernel.h
  37. --- pvfs-2.6.3-pnfsfilelayout/src/kernel/linux-2.6/pvfs2-kernel.h~nfsproclayoutsupport    2008-01-05 17:53:58.000000000 -0800
  38. +++ pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-kernel.h    2008-01-05 17:53:58.000000000 -0800
  39. @@ -171,6 +171,8 @@ sizeof(uint64_t) + sizeof(pvfs2_downcall
  40.  #define MSECS_TO_JIFFIES(ms) (((ms)*HZ+999)/1000)
  41.  #endif
  42.  
  43. +#define PNFS_DATASERVER_LEN 128
  44. +
  45.  /************************************
  46.   * valid pvfs2 kernel operation states
  47.   *
  48. @@ -995,6 +997,7 @@ int service_operation(pvfs2_kernel_op_t*
  49.  
  50.  extern int layouttype;
  51.  extern int layout_stripesize;
  52. +extern char layout_dsnames[];
  53.  
  54.  /** handles two possible error cases, depending on context.
  55.   *
  56. diff -puN src/kernel/linux-2.6/pvfs2-mod.c~nfsproclayoutsupport src/kernel/linux-2.6/pvfs2-mod.c
  57. --- pvfs-2.6.3-pnfsfilelayout/src/kernel/linux-2.6/pvfs2-mod.c~nfsproclayoutsupport    2008-01-05 17:53:58.000000000 -0800
  58. +++ pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-mod.c    2008-01-05 17:53:58.000000000 -0800
  59. @@ -31,6 +31,7 @@ int op_timeout_secs = PVFS2_DEFAULT_OP_T
  60.  
  61.  int layouttype = LAYOUT_PVFS2;
  62.  int layout_stripesize = 65536;
  63. +char layout_dsnames[PNFS_DATASERVER_LEN]; /* comma separated list of file data servers */
  64.  
  65.  MODULE_LICENSE("GPL");
  66.  MODULE_AUTHOR("PVFS2 Development Team");
  67. diff -puN src/kernel/linux-2.6/pvfs2-proc.c~nfsproclayoutsupport src/kernel/linux-2.6/pvfs2-proc.c
  68. --- pvfs-2.6.3-pnfsfilelayout/src/kernel/linux-2.6/pvfs2-proc.c~nfsproclayoutsupport    2008-01-05 17:53:58.000000000 -0800
  69. +++ pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-proc.c    2008-01-05 17:53:58.000000000 -0800
  70. @@ -336,6 +336,9 @@ static ctl_table pvfs2_table[] = {
  71.      {9, "layout_stripesize", &layout_stripesize, sizeof(int), 0644, NULL,
  72.          &proc_dointvec_minmax, &sysctl_intvec,
  73.          NULL, &min_stripesize, &max_stripesize},
  74. +    {10, "layout_ds", &layout_dsnames, PNFS_DATASERVER_LEN, 0644, NULL,
  75. +         &proc_dostring, &sysctl_string,
  76. +     NULL, },
  77.      {0}
  78.  };
  79.  static ctl_table fs_table[] = {
  80. diff -puN src/kernel/linux-2.6/pnfs.c~nfsproclayoutsupport src/kernel/linux-2.6/pnfs.c
  81. --- pvfs-2.6.3-pnfsfilelayout/src/kernel/linux-2.6/pnfs.c~nfsproclayoutsupport    2008-01-05 17:53:58.000000000 -0800
  82. +++ pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pnfs.c    2008-01-05 17:53:58.000000000 -0800
  83. @@ -36,9 +36,19 @@ spinlock_t pvfs2_layout_lock = SPIN_LOCK
  84.  static int
  85.  pvfs2_layout_type(void)
  86.  {
  87. -    return layouttype;
  88. +    int lt;
  89. +
  90. +    /* 5 is a special file layout type that retrieves the
  91. +     * list of data servers from the /proc fs */
  92. +    if (layouttype == 5)
  93. +    lt = LAYOUT_NFSV4_FILES;
  94. +    else
  95. +    lt = layouttype;
  96. +    return lt;
  97.  }
  98.  
  99. +static unsigned int nfsmanual_num_devices;
  100. +
  101.  /****** PVFS2 Layout Functions ******/
  102.  
  103.  /* Set pvfs2 layout information for return to nfsd.
  104. @@ -456,6 +466,96 @@ nfs_getdevicelist(struct super_block *sb
  105.      return ret;
  106.  }
  107.  
  108. +/* Retrieves pvfs2 data layout information about the specified file.
  109. + * return- positive 0
  110. + * negative -ENOSYS or pvfs2_inode_getattr error
  111. + */
  112. +static int
  113. +nfsmanual_layout_get(struct inode * inode, void* buf)
  114. +{
  115. +    int ret;
  116. +    struct nfsd4_pnfs_layoutget *layout_request = (struct nfsd4_pnfs_layoutget*)buf;
  117. +    gossip_debug(GOSSIP_PNFS_DEBUG,"%s: off:%Lu ex:%Lu macc:%d iomode:%d\n", __FUNCTION__,
  118. +         layout_request->lg_seg.offset,
  119. +         layout_request->lg_seg.length,
  120. +         layout_request->lg_mxcnt,
  121. +         layout_request->lg_seg.iomode);
  122. +    ret = nfs_build_layout(layout_request, nfsmanual_num_devices);
  123. +    if (ret)
  124. +    gossip_err("%s: Error!  Could not copy attributes (%d)\n",__FUNCTION__,ret);
  125. +
  126. +    return ret;
  127. +}
  128. +
  129. +/* Generate nfs file device list from devices specified in the /proc fs */
  130. +static int
  131. +nfsmanual_getdevicelist(struct super_block *sb, void *buf)
  132. +{
  133. +    int i=0;
  134. +    struct nfsd4_pnfs_getdevlist *gdevl = (struct nfsd4_pnfs_getdevlist*)buf;
  135. +    struct nfsd4_pnfs_devlist* devlist;
  136. +    struct pnfs_filelayout_devaddr *fdev;
  137. +    char netid[] = "tcp";
  138. +    char nfsport[] = ".8.1";
  139. +    char* t1, *t2;
  140. +    char devs[PNFS_DATASERVER_LEN];
  141. +
  142. +    gossip_debug(GOSSIP_PNFS_DEBUG,"%s: Start\n", __FUNCTION__);
  143. +    gossip_debug(GOSSIP_PNFS_DEBUG,"%s: layout_ds string %s\n", __FUNCTION__, layout_dsnames);
  144. +
  145. +    /* Use at most 8 (number of iota machines) data servers */
  146. +    devlist = (struct nfsd4_pnfs_devlist*)kmalloc(8 * sizeof(struct nfsd4_pnfs_devlist), PVFS2_GFP_FLAGS);
  147. +
  148. +    /* copy devices from proc variable to ensure we don't modify
  149. +     * (which seemed to be happened via strsep)
  150. +     */
  151. +    memcpy(devs, layout_dsnames, PNFS_DATASERVER_LEN);
  152. +    t2 = devs;
  153. +
  154. +    /* todo: ensure space alocated */
  155. +    while ((t1 = strsep(&t2, ","))) {
  156. +    if (!*t1)
  157. +        continue;
  158. +    gossip_debug(GOSSIP_PNFS_DEBUG,"%s: Adding device %s\n", __FUNCTION__, t1);
  159. +    devlist[i].dev_id = i;
  160. +
  161. +    fdev = (struct pnfs_filelayout_devaddr*)kmalloc(
  162. +        sizeof(struct pnfs_filelayout_devaddr), PVFS2_GFP_FLAGS);
  163. +    /* todo ensure space allocated */
  164. +    fdev->r_netid.len = 3;
  165. +    fdev->r_netid.data = (char*)kmalloc(3, PVFS2_GFP_FLAGS);
  166. +    memcpy(fdev->r_netid.data, netid, 3);
  167. +
  168. +    fdev->r_addr.len = strlen(t1);
  169. +    fdev->r_addr.data = (char*)kmalloc(fdev->r_addr.len + 4, PVFS2_GFP_FLAGS);
  170. +    memcpy(fdev->r_addr.data, t1, fdev->r_addr.len);
  171. +
  172. +    /* add port */
  173. +    memcpy(fdev->r_addr.data + fdev->r_addr.len, nfsport, 4);
  174. +    /* Increase by 4 to add the nfs port 2049 */
  175. +    fdev->r_addr.len += 4;
  176. +
  177. +    gossip_debug(GOSSIP_PNFS_DEBUG,"%s: raddrlen: %d raddr: %s\n",
  178. +            __FUNCTION__, fdev->r_addr.len, fdev->r_addr.data);
  179. +    devlist[i].dev_addr = (void*)fdev;
  180. +    i++;
  181. +    }
  182. +
  183. +    gossip_debug(GOSSIP_PNFS_DEBUG,"%s: End\n", __FUNCTION__);
  184. +
  185. +    gdevl->gd_devlist = devlist;
  186. +    gdevl->gd_devlist_len = i;
  187. +
  188. +    /* Set number of devices for layoutget.  This is
  189. +     * ok since a client must always retrieve a list of
  190. +     * devices before it retrieves the layout */
  191. +    nfsmanual_num_devices = i;
  192. +
  193. +    gossip_debug(GOSSIP_PNFS_DEBUG,"%s: End (len: %d)\n", __FUNCTION__, gdevl->gd_devlist_len);
  194. +
  195. +    return 0;
  196. +}
  197. +
  198.  /* export ops for each layout type */
  199.  struct export_operations pvfs2layout_export_ops =
  200.  {
  201. @@ -472,6 +572,13 @@ struct export_operations nfslayout_expor
  202.      .get_devicelist = nfs_getdevicelist,
  203.  };
  204.  
  205. +struct export_operations nfsmanuallayout_export_ops =
  206. +{
  207. +    .layout_type    = pvfs2_layout_type,
  208. +    .layout_get     = nfsmanual_layout_get,
  209. +    .get_devicelist = nfsmanual_getdevicelist,
  210. +};
  211. +
  212.  /*
  213.   * Local variables:
  214.   *  c-indent-level: 4
  215. diff -puN src/kernel/linux-2.6/pvfs2-pnfs.h~nfsproclayoutsupport src/kernel/linux-2.6/pvfs2-pnfs.h
  216. --- pvfs-2.6.3-pnfsfilelayout/src/kernel/linux-2.6/pvfs2-pnfs.h~nfsproclayoutsupport    2008-01-05 17:53:58.000000000 -0800
  217. +++ pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/pvfs2-pnfs.h    2008-01-05 17:53:58.000000000 -0800
  218. @@ -26,6 +26,7 @@ struct pvfs2_layout {
  219.  
  220.  extern struct export_operations pvfs2layout_export_ops;
  221.  extern struct export_operations nfslayout_export_ops;
  222. +extern struct export_operations nfsmanuallayout_export_ops;
  223.  
  224.  /* Structs need to be defined just to compile kernel module since they
  225.   * are used in include/linux/nfs4_pnfs.h.
  226. diff -puN src/kernel/linux-2.6/super.c~nfsproclayoutsupport src/kernel/linux-2.6/super.c
  227. --- pvfs-2.6.3-pnfsfilelayout/src/kernel/linux-2.6/super.c~nfsproclayoutsupport    2008-01-05 17:53:58.000000000 -0800
  228. +++ pvfs-2.6.3-pnfsfilelayout-dhildeb/src/kernel/linux-2.6/super.c    2008-01-05 17:53:58.000000000 -0800
  229. @@ -1108,6 +1108,10 @@ int pvfs2_fill_sb(
  230.          gossip_debug(GOSSIP_PNFS_DEBUG,"Setting nfs layout export ops\n");
  231.          sb->s_export_op = &nfslayout_export_ops;
  232.          break;
  233. +        case 5: /* proc version of files */
  234. +        gossip_debug(GOSSIP_PNFS_DEBUG,"Setting nfs manual layout export ops\n");
  235. +        sb->s_export_op = &nfsmanuallayout_export_ops;
  236. +        break;
  237.          default:
  238.          gossip_err("Invalid layouttype, no export ops to set! (%d)\n", layouttype);
  239.      }
  240. _
  241.