)]}'
{
  "commit": "366100b1403d2b680ed7a0f3bd0ba982c34d5c07",
  "tree": "06dd0162169d3cb550cd24a3e34d0e4d02983ad3",
  "parents": [
    "630a0d87c23900c05ed5906db461ab91d3cc2c27"
  ],
  "author": {
    "name": "Christopher Haster",
    "email": "geky@geky.net",
    "time": "Thu Dec 19 01:32:50 2024 -0600"
  },
  "committer": {
    "name": "Christopher Haster",
    "email": "geky@geky.net",
    "time": "Thu Dec 19 02:39:10 2024 -0600"
  },
  "message": "Fixed incorrect cache reuse when seeking from end-of-block\n\nIn v2.5, we introduced an optimization to avoid rereading data when\nseeking inside the file cache. Unfortunately this used a slightly\nwrong condition to check if the cache was \"live\", which meant seeks from\nend-of-blocks could end up with invalid caches and wrong data. Not\ngreat.\n\nThe problem is the nuance of when a file\u0027s cache is \"live\":\n\n1. The file is marked as LFS_F_READING or LFS_F_WRITING.\n\n   But we can\u0027t reuse the cache when writing, so we only care about\n   LFS_F_READING.\n\n2. file-\u003eoff !\u003d lfs-\u003ecfg-\u003eblock_size (end-of-block).\n\n   This is an optimization to avoid eagerly reading blocks we may not\n   actually care about.\n\nWe weren\u0027t checking for the end-of-block case, which meant if you seeked\n_from_ the end of a block to a seemingly valid location in the file\ncache, you could end up with an invalid cache.\n\nNote that end-of-block may not be powers-of-two due to CTZ skip-list\npointers.\n\n---\n\nThe fix is to check for the end-of-block case in lfs_file_seek. Note\nthis now matches the need-new-block logic in lfs_file_flushedread.\n\nThis logic change may also make lfs_file_seek call lfs_file_flush more\noften, but only in cases where lfs_file_flush is a noop.\n\nI\u0027ve also extended the test_seek tests to cover a few more boundary-read\ncases and prevent a regression in the future.\n\nFound by wjl and lrodorigo\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e92381ae8b926f95a6b8cc424815777e033bf3bd",
      "old_mode": 33188,
      "old_path": "lfs.c",
      "new_id": "7520f2ea7eb1d3d29ab29422ca3d6d0a3057397a",
      "new_mode": 33188,
      "new_path": "lfs.c"
    },
    {
      "type": "modify",
      "old_id": "33fb578590b4f27b2e563bbba1db3caec8830a7f",
      "old_mode": 33188,
      "old_path": "tests/test_seek.toml",
      "new_id": "9856f953c5f373c4ccf4954da326c5b063652e93",
      "new_mode": 33188,
      "new_path": "tests/test_seek.toml"
    }
  ]
}
