Commit c1f55812 authored by Ramon Nou's avatar Ramon Nou
Browse files

fix s3d header behaviour

parent 9ed92167
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1087,9 +1087,10 @@ gkfs_do_write(gkfs::filemap::OpenFile& file, const char* buf, size_t count,
    // This is necessary if the file has inline data but we are now writing
    // beyond the inline limit (or appending).
    bool migrated = false;
    if(gkfs::config::metadata::use_inline_data && (is_append || offset > 0)) {
    if(gkfs::config::metadata::use_inline_data) {
        auto md = gkfs::utils::get_metadata(*path);
        if(md && !md->inline_data().empty()) {
        if(md && md->size() > 0 &&
           md->size() <= gkfs::config::metadata::inline_data_size) {
            LOG(DEBUG, "{}() Migrating inline data to chunks. Size: {}",
                __func__, md->size());
            // Write inline data to chunks
+35 −0
Original line number Diff line number Diff line
@@ -162,4 +162,39 @@ def test_inline_overflow_pwrite(gkfs_daemon, gkfs_client):
    assert read_buf[100:offset] == b'\x00' * (offset - 100)
    assert read_buf[offset:offset+100] == buf2

def test_inline_overwrite_pwrite(gkfs_daemon, gkfs_client):
    """Test pwrite at offset 0 that overflows inline limit (migration/clearing)"""
    file = gkfs_daemon.mountdir / "file_inline_overwrite_pwrite"

    ret = gkfs_client.open(file,
                           os.O_CREAT | os.O_WRONLY,
                           stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
    assert ret.retval != -1

    # Write small inline data
    buf1 = b'A' * 100
    ret = gkfs_client.write(file, buf1, len(buf1))
    assert ret.retval == len(buf1)

    # Overwrite with large data at offset 0
    # This should force chunk write and clear inline data
    buf2 = b'B' * 5000
    ret = gkfs_client.pwrite(file, buf2, len(buf2), 0)
    assert ret.retval == len(buf2)

    # Verify size
    ret = gkfs_client.stat(file)
    assert ret.retval == 0
    assert ret.statbuf.st_size == 5000

    # Verify content
    ret = gkfs_client.open(file,
                           os.O_RDONLY,
                           stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
    assert ret.retval != -1

    ret = gkfs_client.read(file, 5000)
    assert ret.retval == 5000
    assert ret.buf == buf2