Skip to content

Commit

Permalink
Merge pull request #320 from 00pauln00/buffer_set_alt_source_buffer
Browse files Browse the repository at this point in the history
Add 'alternative' buffer source to buffer set
  • Loading branch information
00pauln00 authored Nov 13, 2024
2 parents a38b8c5 + 82b1712 commit 512428e
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: apt update
run: sudo apt update
- name: dpkg / rpm prep (debug)
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/controlplane-recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

# Checkout holon repo
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/golang-apps-recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
cp ./code/scripts/covid_app_recipe.txt ./code/scripts/foodpalaceapp_recipe.txt /home/runner/work/niovad/niovad/build_dir/

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lease_recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:

# Checkout holon repo
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lease_stale_recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:

# Checkout holon repo
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/niova-basic-recipes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
run: cp ./code/scripts/basic_recipes_with_sync.txt /home/runner/work/niovad/niovad/build_dir/

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/niova-bulk-recovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
cp ./code/scripts/bulk_recovery_recipes.txt /home/runner/work/niovad/niovad/build_dir/

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/niova-coalesced-wr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
cp ./code/scripts/coalesced_wr_recipes_with_sync.txt /home/runner/work/niovad/niovad/build_dir/

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/niova-fail-over.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
cp ./code/scripts/failover_recipes.txt /home/runner/work/niovad/niovad/build_dir/

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/niova-prevote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
cp ./code/scripts/prevote_recipes.txt /home/runner/work/niovad/niovad/build_dir/

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/niova-rebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: ./code

Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
cp ./code/scripts/rebuild_recipes.txt /home/runner/work/niovad/niovad/build_dir/

- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: 00pauln00/holon
#ref:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
if: failure()

- name: Archive the test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare_artifact_filename.outputs.ARTIFACT_NAME }}
path: /home/runner/work/niovad/niovad/holon_log
Expand Down
53 changes: 50 additions & 3 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ buffer_set_destroy(struct buffer_set *bs)
buffer_item_user_cache_revoke(bi);

CIRCLEQ_REMOVE(&bs->bs_free_list, bi, bi_lentry);
free(bi->bi_iov.iov_base);

if (!bs->bs_use_alt_source_buf)
free(bi->bi_iov.iov_base);

free(bi);

bs->bs_num_bufs--;
Expand Down Expand Up @@ -449,11 +452,18 @@ buffer_set_destroy(struct buffer_set *bs)
}

int
buffer_set_init(struct buffer_set *bs, size_t nbufs, size_t buf_size,
enum buffer_set_opts opts)
buffer_set_initx(struct buffer_set_args *bsa)
{
buffer_page_size_set();

if (!bsa)
return -EINVAL;

enum buffer_set_opts opts = bsa->bsa_opts;
struct buffer_set *bs = bsa->bsa_set;
size_t buf_size = bsa->bsa_buf_size;
size_t nbufs = bsa->bsa_nbufs;

if (!bs || !buf_size || bs->bs_init)
return -EINVAL;

Expand All @@ -464,6 +474,22 @@ buffer_set_init(struct buffer_set *bs, size_t nbufs, size_t buf_size,
CIRCLEQ_INIT(&bs->bs_free_list);
CIRCLEQ_INIT(&bs->bs_inuse_list);

if (opts & BUFSET_OPT_ALT_SOURCE_BUF)
{
if (bsa->bsa_alt_source == NULL)
return -EINVAL;

if (bsa->bsa_alt_source_size < (nbufs * buf_size))
return -EOVERFLOW;

bsa->bsa_alt_source_used = 0;

bs->bs_alt_source_buf = bsa->bsa_alt_source;
bs->bs_alt_source_buf_size = bsa->bsa_alt_source_size;

bs->bs_use_alt_source_buf = 1;
}

if (opts & BUFSET_OPT_USER_CACHE)
{
bs->bs_allow_user_cache = 1;
Expand Down Expand Up @@ -500,6 +526,13 @@ buffer_set_init(struct buffer_set *bs, size_t nbufs, size_t buf_size,

FATAL_IF(bi->bi_iov.iov_base == NULL, "niova_posix_memalign()");
}
else if (bs->bs_use_alt_source_buf)
{
bi->bi_iov.iov_base =
((char *)bs->bs_alt_source_buf) + bsa->bsa_alt_source_used;

bsa->bsa_alt_source_used += buf_size;
}
else
{
bi->bi_iov.iov_base = malloc(buf_size);
Expand Down Expand Up @@ -547,6 +580,20 @@ buffer_set_init(struct buffer_set *bs, size_t nbufs, size_t buf_size,
return error;
}

int
buffer_set_init(struct buffer_set *bs, size_t nbufs, size_t buf_size,
enum buffer_set_opts opts)
{
struct buffer_set_args bsa = {
.bsa_set = bs,
.bsa_nbufs = nbufs,
.bsa_buf_size = buf_size,
.bsa_opts = opts,
};

return buffer_set_initx(&bsa);
}

int
buffer_set_apply_name(struct buffer_set *bs, const char *name)
{
Expand Down
Loading

0 comments on commit 512428e

Please sign in to comment.