Changeset 8160e4c0 in mainline for uspace/srv/bd/hr/raid5.c


Ignore:
Timestamp:
2024-11-27T13:08:27Z (8 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
40bf2c6
Parents:
bf0a791
git-author:
Miroslav Cimerman <mc@…> (2024-11-27 12:58:10)
git-committer:
Miroslav Cimerman <mc@…> (2024-11-27 13:08:27)
Message:

hr: RAID 4,5: optimize operations with xorbuf

Read block on first iteration directly to
xorbuf. This way one memset and one xor
is saved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/hr/raid5.c

    rbf0a791 r8160e4c0  
    329329
    330330        /* read all other extents in the stripe */
    331         memset(xorbuf, 0, len);
     331        bool first = true;
    332332        for (i = 0; i < vol->dev_no; i++) {
    333                 if (i == bad) {
     333                if (i == bad)
    334334                        continue;
     335
     336                if (first) {
     337                        rc = block_read_direct(vol->extents[i].svc_id, block,
     338                            cnt, xorbuf);
     339                        if (rc != EOK)
     340                                goto end;
     341
     342                        first = false;
    335343                } else {
    336344                        rc = block_read_direct(vol->extents[i].svc_id, block,
     
    391399                 * write new parity
    392400                 */
    393                 memset(xorbuf, 0, len);
     401                bool first = true;
    394402                for (i = 1; i < vol->dev_no; i++) {
    395403                        if (i == (size_t)bad)
    396404                                continue;
     405                        if (first) {
     406                                rc = block_read_direct(vol->extents[i].svc_id,
     407                                    ba, cnt, xorbuf);
     408                                if (rc != EOK)
     409                                        goto end;
     410
     411                                first = false;
    397412                        } else {
    398413                                rc = block_read_direct(vol->extents[i].svc_id,
     
    461476        }
    462477
    463         memset(xorbuf, 0, len);
     478        bool first = true;
    464479        for (i = 0; i < vol->dev_no; i++) {
    465480                if (i == p_extent)
    466481                        continue;
    467                 if (i == extent) {
    468                         xor(xorbuf, data, len);
     482
     483                if (first) {
     484                        if (i == extent) {
     485                                memcpy(xorbuf, data, len);
     486                        } else {
     487                                rc = block_read_direct(vol->extents[i].svc_id,
     488                                    block, cnt, xorbuf);
     489                                if (rc != EOK)
     490                                        goto end;
     491                        }
     492
     493                        first = false;
    469494                } else {
    470                         rc = block_read_direct(vol->extents[i].svc_id,
    471                             block, cnt, buf);
    472                         if (rc != EOK)
    473                                 goto end;
    474                         xor(xorbuf, buf, len);
     495                        if (i == extent) {
     496                                xor(xorbuf, data, len);
     497                        } else {
     498                                rc = block_read_direct(vol->extents[i].svc_id,
     499                                    block, cnt, buf);
     500                                if (rc != EOK)
     501                                        goto end;
     502
     503                                xor(xorbuf, buf, len);
     504                        }
    475505                }
    476506        }
     
    690720                        if (i == bad)
    691721                                continue;
    692                         rc = block_read_direct(vol->extents[i].svc_id, ba, cnt,
    693                             buf);
     722                        if (first)
     723                                rc = block_read_direct(vol->extents[i].svc_id,
     724                                    ba, cnt, xorbuf);
     725                        else
     726                                rc = block_read_direct(vol->extents[i].svc_id,
     727                                    ba, cnt, buf);
    694728                        if (rc != EOK) {
    695729                                hr_raid5_handle_extent_error(vol, i, rc);
     
    700734                        }
    701735
    702                         if (first)
    703                                 memcpy(xorbuf, buf, cnt * vol->bsize);
     736                        if (!first)
     737                                xor(xorbuf, buf, cnt * vol->bsize);
    704738                        else
    705                                 xor(xorbuf, buf, cnt * vol->bsize);
    706 
    707                         first = false;
     739                                first = false;
    708740                }
    709741
Note: See TracChangeset for help on using the changeset viewer.