Guest User

Untitled

a guest
Jun 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. static void ata_rw_virt(struct queue_item *q)
  2. {
  3. struct device *const dev = q->dev;
  4.  
  5. if (G_UNLIKELY(q->ata_hdr.nsect > max_sect_nr(q->iface)))
  6. {
  7. devlog(dev, LOG_ERR, "Request too large (%d)", q->ata_hdr.nsect);
  8. return finish_ata(q, ATA_ABORTED, ATA_DRDY | ATA_ERR);
  9. }
  10. if (G_UNLIKELY(q->is_write && q->length < (unsigned)q->ata_hdr.nsect << 9))
  11. {
  12. devlog(dev, LOG_ERR, "Short write request (have %u, requested %u)",
  13. q->length, (unsigned)q->ata_hdr.nsect << 9);
  14. return finish_ata(q, ATA_ABORTED, ATA_DRDY | ATA_ERR);
  15. }
  16.  
  17. q->length = (unsigned)q->ata_hdr.nsect << 9;
  18. q->is_ata = TRUE;
  19.  
  20. if (q->is_write)
  21. {
  22. struct cs_netlist *nl = dev->dppolicy.encode(q);
  23. struct cs_netlist *nl_tmp = nl;
  24.  
  25. unsigned long long tmp_offset = q->offset;
  26.  
  27. while(nl_tmp)
  28. {
  29. int osds[nl_tmp->count];
  30. /*make outputs for one block*/
  31. block_to_nodes(nl_tmp->count, tmp_offset,
  32. 1,//TODO to have more then virtual disk we must calculate fo wwn's unique int's and hash
  33. osds, NULL); // get list of outputs
  34.  
  35. int i;
  36. for(i = 0; i < nl_tmp->count; i++){
  37. printf("osds[%d] = %d\n", i, osds[i]);
  38.  
  39. device_macs_t *dev_macs = devices_macs;
  40. while (dev_macs)
  41. {
  42. if (dev_macs->device_id == osds[i])
  43. {
  44. printf("aoecmd_ata_rw(buf, %d, %d, %d, %d, %d, %d)\n",
  45. nl_tmp->length,
  46. dev_macs->shelf,
  47. dev_macs->slot,
  48. nl_tmp->writebit,
  49. nl_tmp->extbit,
  50. nl_tmp->offset
  51. );
  52.  
  53. nl_tmp->shelf = dev_macs->shelf;
  54. nl_tmp->slot = dev_macs->slot;
  55. //aoecmd_ata_rw(nl_tmp->buf, nl_tmp->length, dev_macs->shelf, dev_macs->slot, nl_tmp->writebit, nl_tmp->extbit, nl_tmp->offset);
  56. aoecmd_ata_rw(nl_tmp);
  57.  
  58. break;
  59. }
  60. dev_macs=dev_macs->nxt;
  61. }
  62. }
  63.  
  64. tmp_offset += nl_tmp->length;
  65. nl_tmp = nl_tmp->next;
  66. }
  67.  
  68. dev->stats.write_bytes += q->length;
  69. ++dev->stats.write_cnt;
  70. }
  71. else
  72. {
  73. //struct cs_netlist *nl = NULL;
  74. /*TODO!!! CRUCH*/
  75. /*TODO!!! NetWork*/
  76. /*
  77. int err = dev->dppolicy.decode(q, nl);
  78. if(err)
  79. {
  80. devlog(dev, LOG_ERR, "Can not decode request");
  81. return finish_ata(q, ATA_ABORTED, ATA_DRDY | ATA_ERR);
  82. }
  83. */
  84.  
  85. dev->stats.read_bytes += q->length;
  86. ++dev->stats.read_cnt;
  87. }
  88. /* If there are any deferred requests, then mark the device as active
  89. * to ensure run_queue() will get called */
  90. g_ptr_array_add(dev->deferred, q);
  91. activate_dev(dev);
  92. }
  93.  
  94.  
  95. static struct cs_netlist* cs_mirror_dppolicy_encode(struct queue_item *q)
  96. {
  97. struct device *const dev = q->dev;
  98.  
  99. struct cs_netlist *nl_item;
  100. if ((nl_item = malloc(sizeof(struct cs_netlist))) == NULL)
  101. return NULL;
  102.  
  103. nl_item->buf = q->buf;
  104. nl_item->length = q->length;
  105. nl_item->count = dev->dppolicy.k + dev->dppolicy.m;
  106.  
  107. memcpy(nl_item->wwn, dev->cfg.wwn, WWN_ALEN);
  108. nl_item->offset = q->offset;
  109.  
  110. nl_item->writebit = q->is_write;
  111.  
  112.  
  113. nl_item->next = NULL;
  114.  
  115. return nl_item;
  116. }
Add Comment
Please, Sign In to add comment