Skip to content

Instantly share code, notes, and snippets.

@adam900710
Created November 16, 2019 12:12
Show Gist options
  • Save adam900710/77fcd0bc5545fc51147fd8d3385f8419 to your computer and use it in GitHub Desktop.
Save adam900710/77fcd0bc5545fc51147fd8d3385f8419 to your computer and use it in GitHub Desktop.
Sat 16 Nov 2019 08:10:28 PM CST:["lsp#register_server","server registered","clangd"]
Sat 16 Nov 2019 08:10:28 PM CST:["vim-lsp signs enabled"]
Sat 16 Nov 2019 08:10:28 PM CST:["vim-lsp highlighting enabled (textprop)"]
Sat 16 Nov 2019 08:10:28 PM CST:["s:on_text_document_did_open()",1,"c","/home/adam/btrfs/btrfs-progs","file:///home/adam/btrfs/btrfs-progs/disk-io.c"]
Sat 16 Nov 2019 08:10:28 PM CST:[{"response":{"data":{"__data__":"vim-lsp","lsp_id":1,"server_name":"clangd"},"message":"started lsp server successfully"}}]
Sat 16 Nov 2019 08:10:28 PM CST:["--->",1,"clangd",{"method":"initialize","params":{"rootUri":"file:///home/adam/btrfs/btrfs-progs","capabilities":{"workspace":{"configuration":true,"applyEdit":true},"textDocument":{"foldingRange":{"lineFoldingOnly":true},"documentSymbol":{"symbolKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,1,2,3,4,5,6,7,8,9]}},"definition":{"linkSupport":true},"completion":{"completionItem":{"documentationFormat":["plaintext"]},"completionItemKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,1,2,3,4,5,6,7,8,9]}},"implementation":{"linkSupport":true},"declaration":{"linkSupport":true},"typeDefinition":{"linkSupport":true}}},"rootPath":"/home/adam/btrfs/btrfs-progs","processId":57330,"trace":"off"}}]
Sat 16 Nov 2019 08:10:28 PM CST:["<---",1,"clangd",{"response":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"documentHighlightProvider":true,"hoverProvider":true,"workspaceSymbolProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"codeActionProvider":true,"textDocumentSync":2,"declarationProvider":true,"documentOnTypeFormattingProvider":{"moreTriggerCharacter":[],"firstTriggerCharacter":"\n"},"definitionProvider":true,"documentRangeFormattingProvider":true,"typeHierarchyProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"renameProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",">",":"]}}}},"request":{"id":1,"jsonrpc":"2.0","method":"initialize","params":{"rootUri":"file:///home/adam/btrfs/btrfs-progs","capabilities":{"workspace":{"configuration":true,"applyEdit":true},"textDocument":{"foldingRange":{"lineFoldingOnly":true},"documentSymbol":{"symbolKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,1,2,3,4,5,6,7,8,9]}},"definition":{"linkSupport":true},"completion":{"completionItem":{"documentationFormat":["plaintext"]},"completionItemKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,1,2,3,4,5,6,7,8,9]}},"implementation":{"linkSupport":true},"declaration":{"linkSupport":true},"typeDefinition":{"linkSupport":true}}},"rootPath":"/home/adam/btrfs/btrfs-progs","processId":57330,"trace":"off"}}}]
Sat 16 Nov 2019 08:10:28 PM CST:["--->",1,"clangd",{"method":"initialized","params":{}}]
Sat 16 Nov 2019 08:10:28 PM CST:[{"response":{"data":{"__data__":"vim-lsp","server_name":"clangd"},"message":"configuration sent"}}]
Sat 16 Nov 2019 08:10:28 PM CST:["s:update_file_content()",1]
Sat 16 Nov 2019 08:10:28 PM CST:["--->",1,"clangd",{"method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","version":1,"languageId":"c","text":"/*\n * Copyright (C) 2007 Oracle. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or\n * modify it under the terms of the GNU General Public\n * License v2 as published by the Free Software Foundation.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * General Public License for more details.\n *\n * You should have received a copy of the GNU General Public\n * License along with this program; if not, write to the\n * Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n * Boston, MA 021110-1307, USA.\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <unistd.h>\n#include <uuid/uuid.h>\n#include \"kerncompat.h\"\n#include \"kernel-lib/radix-tree.h\"\n#include \"ctree.h\"\n#include \"disk-io.h\"\n#include \"volumes.h\"\n#include \"transaction.h\"\n#include \"kernel-lib/crc32c.h\"\n#include \"common/utils.h\"\n#include \"print-tree.h\"\n#include \"common/rbtree-utils.h\"\n#include \"common/device-scan.h\"\n\n/* specified errno for check_tree_block */\n#define BTRFS_BAD_BYTENR\t\t(-1)\n#define BTRFS_BAD_FSID\t\t\t(-2)\n#define BTRFS_BAD_LEVEL\t\t\t(-3)\n#define BTRFS_BAD_NRITEMS\t\t(-4)\n\n/* Calculate max possible nritems for a leaf/node */\nstatic u32 max_nritems(u8 level, u32 nodesize)\n{\n\n\tif (level == 0)\n\t\treturn ((nodesize - sizeof(struct btrfs_header)) /\n\t\t\tsizeof(struct btrfs_item));\n\treturn ((nodesize - sizeof(struct btrfs_header)) /\n\t\tsizeof(struct btrfs_key_ptr));\n}\n\nstatic int check_tree_block(struct btrfs_fs_info *fs_info,\n\t\t\t struct extent_buffer *buf)\n{\n\n\tstruct btrfs_fs_devices *fs_devices = fs_info->fs_devices;\n\tu32 nodesize = fs_info->nodesize;\n\tbool fsid_match = false;\n\tint ret = BTRFS_BAD_FSID;\n\n\tif (buf->start != btrfs_header_bytenr(buf))\n\t\treturn BTRFS_BAD_BYTENR;\n\tif (btrfs_header_level(buf) >= BTRFS_MAX_LEVEL)\n\t\treturn BTRFS_BAD_LEVEL;\n\tif (btrfs_header_nritems(buf) > max_nritems(btrfs_header_level(buf),\n\t\t\t\t\t\t nodesize))\n\t\treturn BTRFS_BAD_NRITEMS;\n\n\t/* Only leaf can be empty */\n\tif (btrfs_header_nritems(buf) == 0 &&\n\t btrfs_header_level(buf) != 0)\n\t\treturn BTRFS_BAD_NRITEMS;\n\n\twhile (fs_devices) {\n\t /*\n * Checking the incompat flag is only valid for the current\n * fs. For seed devices it's forbidden to have their uuid\n * changed so reading ->fsid in this case is fine\n */\n\t\tif (fs_devices == fs_info->fs_devices &&\n\t\t btrfs_fs_incompat(fs_info, METADATA_UUID))\n\t\t\tfsid_match = !memcmp_extent_buffer(buf,\n\t\t\t\t\t\t fs_devices->metadata_uuid,\n\t\t\t\t\t\t btrfs_header_fsid(),\n\t\t\t\t\t\t BTRFS_FSID_SIZE);\n\t\telse\n\t\t\tfsid_match = !memcmp_extent_buffer(buf,\n\t\t\t\t\t\t fs_devices->fsid,\n\t\t\t\t\t\t btrfs_header_fsid(),\n\t\t\t\t\t\t BTRFS_FSID_SIZE);\n\n\n\t\tif (fs_info->ignore_fsid_mismatch || fsid_match) {\n\t\t\tret = 0;\n\t\t\tbreak;\n\t\t}\n\t\tfs_devices = fs_devices->seed;\n\t}\n\treturn ret;\n}\n\nstatic void print_tree_block_error(struct btrfs_fs_info *fs_info,\n\t\t\t\tstruct extent_buffer *eb,\n\t\t\t\tint err)\n{\n\tchar fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = {'\\0'};\n\tchar found_uuid[BTRFS_UUID_UNPARSED_SIZE] = {'\\0'};\n\tu8 buf[BTRFS_UUID_SIZE];\n\n\tif (!err)\n\t\treturn;\n\n\tfprintf(stderr, \"bad tree block %llu, \", eb->start);\n\tswitch (err) {\n\tcase BTRFS_BAD_FSID:\n\t\tread_extent_buffer(eb, buf, btrfs_header_fsid(),\n\t\t\t\t BTRFS_UUID_SIZE);\n\t\tuuid_unparse(buf, found_uuid);\n\t\tuuid_unparse(fs_info->fs_devices->metadata_uuid, fs_uuid);\n\t\tfprintf(stderr, \"fsid mismatch, want=%s, have=%s\\n\",\n\t\t\tfs_uuid, found_uuid);\n\t\tbreak;\n\tcase BTRFS_BAD_BYTENR:\n\t\tfprintf(stderr, \"bytenr mismatch, want=%llu, have=%llu\\n\",\n\t\t\teb->start, btrfs_header_bytenr(eb));\n\t\tbreak;\n\tcase BTRFS_BAD_LEVEL:\n\t\tfprintf(stderr, \"bad level, %u > %d\\n\",\n\t\t\tbtrfs_header_level(eb), BTRFS_MAX_LEVEL);\n\t\tbreak;\n\tcase BTRFS_BAD_NRITEMS:\n\t\tfprintf(stderr, \"invalid nr_items: %u\\n\",\n\t\t\tbtrfs_header_nritems(eb));\n\t\tbreak;\n\t}\n}\n\nint btrfs_csum_data(u16 csum_type, const u8 *data, u8 *out, size_t len)\n{\n\tu32 crc = ~(u32)0;\n\n\tmemset(out, 0, BTRFS_CSUM_SIZE);\n\n\tswitch (csum_type) {\n\tcase BTRFS_CSUM_TYPE_CRC32:\n\t\tcrc = crc32c(crc, data, len);\n\t\tput_unaligned_le32(~crc, out);\n\t\treturn 0;\n\tdefault:\n\t\tfprintf(stderr, \"ERROR: unknown csum type: %d\\n\", csum_type);\n\t\tASSERT(0);\n\t}\n\n\treturn -1;\n}\n\nstatic int __csum_tree_block_size(struct extent_buffer *buf, u16 csum_size,\n\t\t\t\t int verify, int silent, u16 csum_type)\n{\n\tu8 result[BTRFS_CSUM_SIZE];\n\tu32 len;\n\n\tlen = buf->len - BTRFS_CSUM_SIZE;\n\tbtrfs_csum_data(csum_type, (u8 *)buf->data + BTRFS_CSUM_SIZE,\n\t\t\tresult, len);\n\n\tif (verify) {\n\t\tif (memcmp_extent_buffer(buf, result, 0, csum_size)) {\n\t\t\t/* FIXME: format */\n\t\t\tif (!silent)\n\t\t\t\tprintk(\"checksum verify failed on %llu found %08X wanted %08X\\n\",\n\t\t\t\t (unsigned long long)buf->start,\n\t\t\t\t result[0],\n\t\t\t\t buf->data[0]);\n\t\t\treturn 1;\n\t\t}\n\t} else {\n\t\twrite_extent_buffer(buf, result, 0, csum_size);\n\t}\n\treturn 0;\n}\n\nint csum_tree_block_size(struct extent_buffer *buf, u16 csum_size, int verify,\n\t\t\t u16 csum_type)\n{\n\treturn __csum_tree_block_size(buf, csum_size, verify, 0, csum_type);\n}\n\nint verify_tree_block_csum_silent(struct extent_buffer *buf, u16 csum_size,\n\t\t\t\t u16 csum_type)\n{\n\treturn __csum_tree_block_size(buf, csum_size, 1, 1, csum_type);\n}\n\nint csum_tree_block(struct btrfs_fs_info *fs_info,\n\t\t struct extent_buffer *buf, int verify)\n{\n\tu16 csum_size = btrfs_super_csum_size(fs_info->super_copy);\n\tu16 csum_type = btrfs_super_csum_type(fs_info->super_copy);\n\n\tif (verify && fs_info->suppress_check_block_errors)\n\t\treturn verify_tree_block_csum_silent(buf, csum_size, csum_type);\n\treturn csum_tree_block_size(buf, csum_size, verify, csum_type);\n}\n\nstruct extent_buffer *btrfs_find_tree_block(struct btrfs_fs_info *fs_info,\n\t\t\t\t\t u64 bytenr, u32 blocksize)\n{\n\treturn find_extent_buffer(&fs_info->extent_cache,\n\t\t\t\t bytenr, blocksize);\n}\n\nstruct extent_buffer* btrfs_find_create_tree_block(\n\t\tstruct btrfs_fs_info *fs_info, u64 bytenr)\n{\n\treturn alloc_extent_buffer(fs_info, bytenr, fs_info->nodesize);\n}\n\nvoid readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,\n\t\tu64 parent_transid)\n{\n\tstruct extent_buffer *eb;\n\tu64 length;\n\tstruct btrfs_multi_bio *multi = NULL;\n\tstruct btrfs_device *device;\n\n\teb = btrfs_find_tree_block(fs_info, bytenr, fs_info->nodesize);\n\tif (!(eb && btrfs_buffer_uptodate(eb, parent_transid)) &&\n\t !btrfs_map_block(fs_info, READ, bytenr, &length, &multi, 0,\n\t\t\t NULL)) {\n\t\tdevice = multi->stripes[0].dev;\n\t\tdevice->total_ios++;\n\t\treadahead(device->fd, multi->stripes[0].physical,\n\t\t\t\tfs_info->nodesize);\n\t}\n\n\tfree_extent_buffer(eb);\n\tkfree(multi);\n}\n\nstatic int verify_parent_transid(struct extent_io_tree *io_tree,\n\t\t\t\t struct extent_buffer *eb, u64 parent_transid,\n\t\t\t\t int ignore)\n{\n\tint ret;\n\n\tif (!parent_transid || btrfs_header_generation(eb) == parent_transid)\n\t\treturn 0;\n\n\tif (extent_buffer_uptodate(eb) &&\n\t btrfs_header_generation(eb) == parent_transid) {\n\t\tret = 0;\n\t\tgoto out;\n\t}\n\tprintk(\"parent transid verify failed on %llu wanted %llu found %llu\\n\",\n\t (unsigned long long)eb->start,\n\t (unsigned long long)parent_transid,\n\t (unsigned long long)btrfs_header_generation(eb));\n\tif (ignore) {\n\t\teb->flags |= EXTENT_BAD_TRANSID;\n\t\tprintk(\"Ignoring transid failure\\n\");\n\t\treturn 0;\n\t}\n\n\tret = 1;\nout:\n\tclear_extent_buffer_uptodate(eb);\n\treturn ret;\n\n}\n\n\nint read_whole_eb(struct btrfs_fs_info *info, struct extent_buffer *eb, int mirror)\n{\n\tunsigned long offset = 0;\n\tstruct btrfs_multi_bio *multi = NULL;\n\tstruct btrfs_device *device;\n\tint ret = 0;\n\tu64 read_len;\n\tunsigned long bytes_left = eb->len;\n\n\twhile (bytes_left) {\n\t\tread_len = bytes_left;\n\t\tdevice = NULL;\n\n\t\tif (!info->on_restoring &&\n\t\t eb->start != BTRFS_SUPER_INFO_OFFSET) {\n\t\t\tret = btrfs_map_block(info, READ, eb->start + offset,\n\t\t\t\t\t &read_len, &multi, mirror, NULL);\n\t\t\tif (ret) {\n\t\t\t\tprintk(\"Couldn't map the block %Lu\\n\", eb->start + offset);\n\t\t\t\tkfree(multi);\n\t\t\t\treturn -EIO;\n\t\t\t}\n\t\t\tdevice = multi->stripes[0].dev;\n\n\t\t\tif (device->fd <= 0) {\n\t\t\t\tkfree(multi);\n\t\t\t\treturn -EIO;\n\t\t\t}\n\n\t\t\teb->fd = device->fd;\n\t\t\tdevice->total_ios++;\n\t\t\teb->dev_bytenr = multi->stripes[0].physical;\n\t\t\tkfree(multi);\n\t\t\tmulti = NULL;\n\t\t} else {\n\t\t\t/* special case for restore metadump */\n\t\t\tlist_for_each_entry(device, &info->fs_devices->devices, dev_list) {\n\t\t\t\tif (device->devid == 1)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\teb->fd = device->fd;\n\t\t\teb->dev_bytenr = eb->start;\n\t\t\tdevice->total_ios++;\n\t\t}\n\n\t\tif (read_len > bytes_left)\n\t\t\tread_len = bytes_left;\n\n\t\tret = read_extent_from_disk(eb, offset, read_len);\n\t\tif (ret)\n\t\t\treturn -EIO;\n\t\toffset += read_len;\n\t\tbytes_left -= read_len;\n\t}\n\treturn 0;\n}\n\nstruct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,\n\t\tu64 parent_transid)\n{\n\tint ret;\n\tstruct extent_buffer *eb;\n\tu64 best_transid = 0;\n\tu32 sectorsize = fs_info->sectorsize;\n\tint mirror_num = 1;\n\tint good_mirror = 0;\n\tint candidate_mirror = 0;\n\tint num_copies;\n\tint ignore = 0;\n\n\t/*\n\t * Don't even try to create tree block for unaligned tree block\n\t * bytenr.\n\t * Such unaligned tree block will free overlapping extent buffer,\n\t * causing use-after-free bugs for fuzzed images.\n\t */\n\tif (bytenr < sectorsize || !IS_ALIGNED(bytenr, sectorsize)) {\n\t\terror(\"tree block bytenr %llu is not aligned to sectorsize %u\",\n\t\t bytenr, sectorsize);\n\t\treturn ERR_PTR(-EIO);\n\t}\n\n\teb = btrfs_find_create_tree_block(fs_info, bytenr);\n\tif (!eb)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tif (btrfs_buffer_uptodate(eb, parent_transid))\n\t\treturn eb;\n\n\tnum_copies = btrfs_num_copies(fs_info, eb->start, eb->len);\n\twhile (1) {\n\t\tret = read_whole_eb(fs_info, eb, mirror_num);\n\t\tif (ret == 0 && csum_tree_block(fs_info, eb, 1) == 0 &&\n\t\t check_tree_block(fs_info, eb) == 0 &&\n\t\t verify_parent_transid(eb->tree, eb, parent_transid, ignore)\n\t\t == 0) {\n\t\t\tif (eb->flags & EXTENT_BAD_TRANSID &&\n\t\t\t list_empty(&eb->recow)) {\n\t\t\t\tlist_add_tail(&eb->recow,\n\t\t\t\t\t &fs_info->recow_ebs);\n\t\t\t\teb->refs++;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * check_tree_block() is less strict to allow btrfs\n\t\t\t * check to get raw eb with bad key order and fix it.\n\t\t\t * But we still need to try to get a good copy if\n\t\t\t * possible, or bad key order can go into tools like\n\t\t\t * btrfs ins dump-tree.\n\t\t\t */\n\t\t\tif (btrfs_header_level(eb))\n\t\t\t\tret = btrfs_check_node(fs_info, NULL, eb);\n\t\t\telse\n\t\t\t\tret = btrfs_check_leaf(fs_info, NULL, eb);\n\t\t\tif (!ret || candidate_mirror == mirror_num) {\n\t\t\t\tbtrfs_set_buffer_uptodate(eb);\n\t\t\t\treturn eb;\n\t\t\t}\n\t\t\tif (candidate_mirror <= 0)\n\t\t\t\tcandidate_mirror = mirror_num;\n\t\t}\n\t\tif (ignore) {\n\t\t\tif (candidate_mirror > 0) {\n\t\t\t\tmirror_num = candidate_mirror;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (check_tree_block(fs_info, eb)) {\n\t\t\t\tif (!fs_info->suppress_check_block_errors)\n\t\t\t\t\tprint_tree_block_error(fs_info, eb,\n\t\t\t\t\t\tcheck_tree_block(fs_info, eb));\n\t\t\t} else {\n\t\t\t\tif (!fs_info->suppress_check_block_errors)\n\t\t\t\t\tfprintf(stderr, \"Csum didn't match\\n\");\n\t\t\t}\n\t\t\tret = -EIO;\n\t\t\tbreak;\n\t\t}\n\t\tif (num_copies == 1) {\n\t\t\tignore = 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (btrfs_header_generation(eb) > best_transid) {\n\t\t\tbest_transid = btrfs_header_generation(eb);\n\t\t\tgood_mirror = mirror_num;\n\t\t}\n\t\tmirror_num++;\n\t\tif (mirror_num > num_copies) {\n\t\t\tif (candidate_mirror > 0)\n\t\t\t\tmirror_num = candidate_mirror;\n\t\t\telse\n\t\t\t\tmirror_num = good_mirror;\n\t\t\tignore = 1;\n\t\t\tcontinue;\n\t\t}\n\t}\n\t/*\n\t * We failed to read this tree block, it be should deleted right now\n\t * to avoid stale cache populate the cache.\n\t */\n\tfree_extent_buffer_nocache(eb);\n\treturn ERR_PTR(ret);\n}\n\nint read_extent_data(struct btrfs_fs_info *fs_info, char *data, u64 logical,\n\t\t u64 *len, int mirror)\n{\n\tu64 offset = 0;\n\tstruct btrfs_multi_bio *multi = NULL;\n\tstruct btrfs_device *device;\n\tint ret = 0;\n\tu64 max_len = *len;\n\n\tret = btrfs_map_block(fs_info, READ, logical, len, &multi, mirror,\n\t\t\t NULL);\n\tif (ret) {\n\t\tfprintf(stderr, \"Couldn't map the block %llu\\n\",\n\t\t\t\tlogical + offset);\n\t\tgoto err;\n\t}\n\tdevice = multi->stripes[0].dev;\n\n\tif (*len > max_len)\n\t\t*len = max_len;\n\tif (device->fd < 0) {\n\t\tret = -EIO;\n\t\tgoto err;\n\t}\n\n\tret = pread64(device->fd, data, *len, multi->stripes[0].physical);\n\tif (ret != *len)\n\t\tret = -EIO;\n\telse\n\t\tret = 0;\nerr:\n\tkfree(multi);\n\treturn ret;\n}\n\nint write_and_map_eb(struct btrfs_fs_info *fs_info, struct extent_buffer *eb)\n{\n\tint ret;\n\tint dev_nr;\n\tu64 length;\n\tu64 *raid_map = NULL;\n\tstruct btrfs_multi_bio *multi = NULL;\n\n\tdev_nr = 0;\n\tlength = eb->len;\n\tret = btrfs_map_block(fs_info, WRITE, eb->start, &length,\n\t\t\t &multi, 0, &raid_map);\n\n\tif (raid_map) {\n\t\tret = write_raid56_with_parity(fs_info, eb, multi,\n\t\t\t\t\t length, raid_map);\n\t\tBUG_ON(ret);\n\t} else while (dev_nr < multi->num_stripes) {\n\t\tBUG_ON(ret);\n\t\teb->fd = multi->stripes[dev_nr].dev->fd;\n\t\teb->dev_bytenr = multi->stripes[dev_nr].physical;\n\t\tmulti->stripes[dev_nr].dev->total_ios++;\n\t\tdev_nr++;\n\t\tret = write_extent_to_disk(eb);\n\t\tBUG_ON(ret);\n\t}\n\tkfree(raid_map);\n\tkfree(multi);\n\treturn 0;\n}\n\nint write_tree_block(struct btrfs_trans_handle *trans,\n\t\t struct btrfs_fs_info *fs_info,\n\t\t struct extent_buffer *eb)\n{\n\tif (check_tree_block(fs_info, eb)) {\n\t\tprint_tree_block_error(fs_info, eb,\n\t\t\t\tcheck_tree_block(fs_info, eb));\n\t\tBUG();\n\t}\n\n\tif (trans && !btrfs_buffer_uptodate(eb, trans->transid))\n\t\tBUG();\n\n\tbtrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN);\n\tcsum_tree_block(fs_info, eb, 0);\n\n\treturn write_and_map_eb(fs_info, eb);\n}\n\nvoid btrfs_setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,\n\t\t u64 objectid)\n{\n\troot->node = NULL;\n\troot->commit_root = NULL;\n\troot->ref_cows = 0;\n\troot->track_dirty = 0;\n\n\troot->fs_info = fs_info;\n\troot->objectid = objectid;\n\troot->last_trans = 0;\n\troot->last_inode_alloc = 0;\n\n\tINIT_LIST_HEAD(&root->dirty_list);\n\tINIT_LIST_HEAD(&root->unaligned_extent_recs);\n\tmemset(&root->root_key, 0, sizeof(root->root_key));\n\tmemset(&root->root_item, 0, sizeof(root->root_item));\n\troot->root_key.objectid = objectid;\n}\n\nstatic int find_and_setup_root(struct btrfs_root *tree_root,\n\t\t\t struct btrfs_fs_info *fs_info,\n\t\t\t u64 objectid, struct btrfs_root *root)\n{\n\tint ret;\n\tu64 generation;\n\n\tbtrfs_setup_root(root, fs_info, objectid);\n\tret = btrfs_find_last_root(tree_root, objectid,\n\t\t\t\t &root->root_item, &root->root_key);\n\tif (ret)\n\t\treturn ret;\n\n\tgeneration = btrfs_root_generation(&root->root_item);\n\troot->node = read_tree_block(fs_info,\n\t\t\tbtrfs_root_bytenr(&root->root_item), generation);\n\tif (!extent_buffer_uptodate(root->node))\n\t\treturn -EIO;\n\n\treturn 0;\n}\n\nstatic int find_and_setup_log_root(struct btrfs_root *tree_root,\n\t\t\t struct btrfs_fs_info *fs_info,\n\t\t\t struct btrfs_super_block *disk_super)\n{\n\tu64 blocknr = btrfs_super_log_root(disk_super);\n\tstruct btrfs_root *log_root = malloc(sizeof(struct btrfs_root));\n\n\tif (!log_root)\n\t\treturn -ENOMEM;\n\n\tif (blocknr == 0) {\n\t\tfree(log_root);\n\t\treturn 0;\n\t}\n\n\tbtrfs_setup_root(log_root, fs_info,\n\t\t\t BTRFS_TREE_LOG_OBJECTID);\n\n\tlog_root->node = read_tree_block(fs_info, blocknr,\n\t\t\t\t btrfs_super_generation(disk_super) + 1);\n\n\tfs_info->log_root_tree = log_root;\n\n\tif (!extent_buffer_uptodate(log_root->node)) {\n\t\tfree_extent_buffer(log_root->node);\n\t\tfree(log_root);\n\t\tfs_info->log_root_tree = NULL;\n\t\treturn -EIO;\n\t}\n\n\treturn 0;\n}\n\nint btrfs_free_fs_root(struct btrfs_root *root)\n{\n\tif (root->node)\n\t\tfree_extent_buffer(root->node);\n\tif (root->commit_root)\n\t\tfree_extent_buffer(root->commit_root);\n\tkfree(root);\n\treturn 0;\n}\n\nstatic void __free_fs_root(struct rb_node *node)\n{\n\tstruct btrfs_root *root;\n\n\troot = container_of(node, struct btrfs_root, rb_node);\n\tbtrfs_free_fs_root(root);\n}\n\nFREE_RB_BASED_TREE(fs_roots, __free_fs_root);\n\nstruct btrfs_root *btrfs_read_fs_root_no_cache(struct btrfs_fs_info *fs_info,\n\t\t\t\t\t struct btrfs_key *location)\n{\n\tstruct btrfs_root *root;\n\tstruct btrfs_root *tree_root = fs_info->tree_root;\n\tstruct btrfs_path *path;\n\tstruct extent_buffer *l;\n\tu64 generation;\n\tint ret = 0;\n\n\troot = calloc(1, sizeof(*root));\n\tif (!root)\n\t\treturn ERR_PTR(-ENOMEM);\n\tif (location->offset == (u64)-1) {\n\t\tret = find_and_setup_root(tree_root, fs_info,\n\t\t\t\t\t location->objectid, root);\n\t\tif (ret) {\n\t\t\tfree(root);\n\t\t\treturn ERR_PTR(ret);\n\t\t}\n\t\tgoto insert;\n\t}\n\n\tbtrfs_setup_root(root, fs_info,\n\t\t\t location->objectid);\n\n\tpath = btrfs_alloc_path();\n\tif (!path) {\n\t\tfree(root);\n\t\treturn ERR_PTR(-ENOMEM);\n\t}\n\n\tret = btrfs_search_slot(NULL, tree_root, location, path, 0, 0);\n\tif (ret != 0) {\n\t\tif (ret > 0)\n\t\t\tret = -ENOENT;\n\t\tgoto out;\n\t}\n\tl = path->nodes[0];\n\tread_extent_buffer(l, &root->root_item,\n\t btrfs_item_ptr_offset(l, path->slots[0]),\n\t sizeof(root->root_item));\n\tmemcpy(&root->root_key, location, sizeof(*location));\n\tret = 0;\nout:\n\tbtrfs_free_path(path);\n\tif (ret) {\n\t\tfree(root);\n\t\treturn ERR_PTR(ret);\n\t}\n\tgeneration = btrfs_root_generation(&root->root_item);\n\troot->node = read_tree_block(fs_info,\n\t\t\tbtrfs_root_bytenr(&root->root_item), generation);\n\tif (!extent_buffer_uptodate(root->node)) {\n\t\tfree(root);\n\t\treturn ERR_PTR(-EIO);\n\t}\ninsert:\n\troot->ref_cows = 1;\n\treturn root;\n}\n\nstatic int btrfs_fs_roots_compare_objectids(struct rb_node *node,\n\t\t\t\t\t void *data)\n{\n\tu64 objectid = *((u64 *)data);\n\tstruct btrfs_root *root;\n\n\troot = rb_entry(node, struct btrfs_root, rb_node);\n\tif (objectid > root->objectid)\n\t\treturn 1;\n\telse if (objectid < root->objectid)\n\t\treturn -1;\n\telse\n\t\treturn 0;\n}\n\nint btrfs_fs_roots_compare_roots(struct rb_node *node1, struct rb_node *node2)\n{\n\tstruct btrfs_root *root;\n\n\troot = rb_entry(node2, struct btrfs_root, rb_node);\n\treturn btrfs_fs_roots_compare_objectids(node1, (void *)&root->objectid);\n}\n\nstruct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,\n\t\t\t\t struct btrfs_key *location)\n{\n\tstruct btrfs_root *root;\n\tstruct rb_node *node;\n\tint ret;\n\tu64 objectid = location->objectid;\n\n\tif (location->objectid == BTRFS_ROOT_TREE_OBJECTID)\n\t\treturn fs_info->tree_root;\n\tif (location->objectid == BTRFS_EXTENT_TREE_OBJECTID)\n\t\treturn fs_info->extent_root;\n\tif (location->objectid == BTRFS_CHUNK_TREE_OBJECTID)\n\t\treturn fs_info->chunk_root;\n\tif (location->objectid == BTRFS_DEV_TREE_OBJECTID)\n\t\treturn fs_info->dev_root;\n\tif (location->objectid == BTRFS_CSUM_TREE_OBJECTID)\n\t\treturn fs_info->csum_root;\n\tif (location->objectid == BTRFS_UUID_TREE_OBJECTID)\n\t\treturn fs_info->uuid_root ? fs_info->uuid_root : ERR_PTR(-ENOENT);\n\tif (location->objectid == BTRFS_QUOTA_TREE_OBJECTID)\n\t\treturn fs_info->quota_enabled ? fs_info->quota_root :\n\t\t\t\tERR_PTR(-ENOENT);\n\tif (location->objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)\n\t\treturn fs_info->free_space_root ? fs_info->free_space_root :\n\t\t\t\t\t\tERR_PTR(-ENOENT);\n\n\tBUG_ON(location->objectid == BTRFS_TREE_RELOC_OBJECTID ||\n\t location->offset != (u64)-1);\n\n\tnode = rb_search(&fs_info->fs_root_tree, (void *)&objectid,\n\t\t\t btrfs_fs_roots_compare_objectids, NULL);\n\tif (node)\n\t\treturn container_of(node, struct btrfs_root, rb_node);\n\n\troot = btrfs_read_fs_root_no_cache(fs_info, location);\n\tif (IS_ERR(root))\n\t\treturn root;\n\n\tret = rb_insert(&fs_info->fs_root_tree, &root->rb_node,\n\t\t\tbtrfs_fs_roots_compare_roots);\n\tBUG_ON(ret);\n\treturn root;\n}\n\nvoid btrfs_free_fs_info(struct btrfs_fs_info *fs_info)\n{\n\tif (fs_info->quota_root)\n\t\tfree(fs_info->quota_root);\n\n\tfree(fs_info->tree_root);\n\tfree(fs_info->extent_root);\n\tfree(fs_info->chunk_root);\n\tfree(fs_info->dev_root);\n\tfree(fs_info->csum_root);\n\tfree(fs_info->free_space_root);\n\tfree(fs_info->uuid_root);\n\tfree(fs_info->super_copy);\n\tfree(fs_info->log_root_tree);\n\tfree(fs_info);\n}\n\nstruct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr)\n{\n\tstruct btrfs_fs_info *fs_info;\n\n\tfs_info = calloc(1, sizeof(struct btrfs_fs_info));\n\tif (!fs_info)\n\t\treturn NULL;\n\n\tfs_info->tree_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->extent_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->chunk_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->dev_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->csum_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->quota_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->free_space_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->uuid_root = calloc(1, sizeof(struct btrfs_root));\n\tfs_info->super_copy = calloc(1, BTRFS_SUPER_INFO_SIZE);\n\n\tif (!fs_info->tree_root || !fs_info->extent_root ||\n\t !fs_info->chunk_root || !fs_info->dev_root ||\n\t !fs_info->csum_root || !fs_info->quota_root ||\n\t !fs_info->free_space_root || !fs_info->uuid_root ||\n\t !fs_info->super_copy)\n\t\tgoto free_all;\n\n\textent_io_tree_init(&fs_info->extent_cache);\n\textent_io_tree_init(&fs_info->free_space_cache);\n\textent_io_tree_init(&fs_info->block_group_cache);\n\textent_io_tree_init(&fs_info->pinned_extents);\n\textent_io_tree_init(&fs_info->extent_ins);\n\tfs_info->excluded_extents = NULL;\n\n\tfs_info->fs_root_tree = RB_ROOT;\n\tcache_tree_init(&fs_info->mapping_tree.cache_tree);\n\n\tmutex_init(&fs_info->fs_mutex);\n\tINIT_LIST_HEAD(&fs_info->dirty_cowonly_roots);\n\tINIT_LIST_HEAD(&fs_info->space_info);\n\tINIT_LIST_HEAD(&fs_info->recow_ebs);\n\n\tif (!writable)\n\t\tfs_info->readonly = 1;\n\n\tfs_info->super_bytenr = sb_bytenr;\n\tfs_info->data_alloc_profile = (u64)-1;\n\tfs_info->metadata_alloc_profile = (u64)-1;\n\tfs_info->system_alloc_profile = fs_info->metadata_alloc_profile;\n\treturn fs_info;\nfree_all:\n\tbtrfs_free_fs_info(fs_info);\n\treturn NULL;\n}\n\nint btrfs_check_fs_compatibility(struct btrfs_super_block *sb,\n\t\t\t\t unsigned int flags)\n{\n\tu64 features;\n\n\tfeatures = btrfs_super_incompat_flags(sb) &\n\t\t ~BTRFS_FEATURE_INCOMPAT_SUPP;\n\tif (features) {\n\t\tprintk(\"couldn't open because of unsupported \"\n\t\t \"option features (%llx).\\n\",\n\t\t (unsigned long long)features);\n\t\treturn -ENOTSUP;\n\t}\n\n\tfeatures = btrfs_super_incompat_flags(sb);\n\tif (!(features & BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF)) {\n\t\tfeatures |= BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF;\n\t\tbtrfs_set_super_incompat_flags(sb, features);\n\t}\n\n\tfeatures = btrfs_super_compat_ro_flags(sb);\n\tif (flags & OPEN_CTREE_WRITES) {\n\t\tif (flags & OPEN_CTREE_INVALIDATE_FST) {\n\t\t\t/* Clear the FREE_SPACE_TREE_VALID bit on disk... */\n\t\t\tfeatures &= ~BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID;\n\t\t\tbtrfs_set_super_compat_ro_flags(sb, features);\n\t\t\t/* ... and ignore the free space tree bit. */\n\t\t\tfeatures &= ~BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE;\n\t\t}\n\t\tif (features & ~BTRFS_FEATURE_COMPAT_RO_SUPP) {\n\t\t\tprintk(\"couldn't open RDWR because of unsupported \"\n\t\t\t \"option features (0x%llx)\\n\",\n\t\t\t (unsigned long long)features);\n\t\t\treturn -ENOTSUP;\n\t\t}\n\n\t}\n\treturn 0;\n}\n\nstatic int find_best_backup_root(struct btrfs_super_block *super)\n{\n\tstruct btrfs_root_backup *backup;\n\tu64 orig_gen = btrfs_super_generation(super);\n\tu64 gen = 0;\n\tint best_index = 0;\n\tint i;\n\n\tfor (i = 0; i < BTRFS_NUM_BACKUP_ROOTS; i++) {\n\t\tbackup = super->super_roots + i;\n\t\tif (btrfs_backup_tree_root_gen(backup) != orig_gen &&\n\t\t btrfs_backup_tree_root_gen(backup) > gen) {\n\t\t\tbest_index = i;\n\t\t\tgen = btrfs_backup_tree_root_gen(backup);\n\t\t}\n\t}\n\treturn best_index;\n}\n\nstatic int setup_root_or_create_block(struct btrfs_fs_info *fs_info,\n\t\t\t\t unsigned flags,\n\t\t\t\t struct btrfs_root *info_root,\n\t\t\t\t u64 objectid, char *str)\n{\n\tstruct btrfs_root *root = fs_info->tree_root;\n\tint ret;\n\n\tret = find_and_setup_root(root, fs_info, objectid, info_root);\n\tif (ret) {\n\t\tif (!(flags & OPEN_CTREE_PARTIAL)) {\n\t\t\terror(\"could not setup %s tree\", str);\n\t\t\treturn -EIO;\n\t\t}\n\t\twarning(\"could not setup %s tree, skipping it\", str);\n\t\t/*\n\t\t * Need a blank node here just so we don't screw up in the\n\t\t * million of places that assume a root has a valid ->node\n\t\t */\n\t\tinfo_root->node =\n\t\t\tbtrfs_find_create_tree_block(fs_info, 0);\n\t\tif (!info_root->node)\n\t\t\treturn -ENOMEM;\n\t\tclear_extent_buffer_uptodate(info_root->node);\n\t}\n\n\treturn 0;\n}\n\nint btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,\n\t\t\t unsigned flags)\n{\n\tstruct btrfs_super_block *sb = fs_info->super_copy;\n\tstruct btrfs_root *root;\n\tstruct btrfs_key key;\n\tu64 generation;\n\tint ret;\n\n\troot = fs_info->tree_root;\n\tbtrfs_setup_root(root, fs_info, BTRFS_ROOT_TREE_OBJECTID);\n\tgeneration = btrfs_super_generation(sb);\n\n\tif (!root_tree_bytenr && !(flags & OPEN_CTREE_BACKUP_ROOT)) {\n\t\troot_tree_bytenr = btrfs_super_root(sb);\n\t} else if (flags & OPEN_CTREE_BACKUP_ROOT) {\n\t\tstruct btrfs_root_backup *backup;\n\t\tint index = find_best_backup_root(sb);\n\t\tif (index >= BTRFS_NUM_BACKUP_ROOTS) {\n\t\t\tfprintf(stderr, \"Invalid backup root number\\n\");\n\t\t\treturn -EIO;\n\t\t}\n\t\tbackup = fs_info->super_copy->super_roots + index;\n\t\troot_tree_bytenr = btrfs_backup_tree_root(backup);\n\t\tgeneration = btrfs_backup_tree_root_gen(backup);\n\t}\n\n\troot->node = read_tree_block(fs_info, root_tree_bytenr, generation);\n\tif (!extent_buffer_uptodate(root->node)) {\n\t\tfprintf(stderr, \"Couldn't read tree root\\n\");\n\t\treturn -EIO;\n\t}\n\n\tret = setup_root_or_create_block(fs_info, flags, fs_info->extent_root,\n\t\t\t\t\t BTRFS_EXTENT_TREE_OBJECTID, \"extent\");\n\tif (ret)\n\t\treturn ret;\n\tfs_info->extent_root->track_dirty = 1;\n\n\tret = find_and_setup_root(root, fs_info, BTRFS_DEV_TREE_OBJECTID,\n\t\t\t\t fs_info->dev_root);\n\tif (ret) {\n\t\tprintk(\"Couldn't setup device tree\\n\");\n\t\treturn -EIO;\n\t}\n\tfs_info->dev_root->track_dirty = 1;\n\n\tret = setup_root_or_create_block(fs_info, flags, fs_info->csum_root,\n\t\t\t\t\t BTRFS_CSUM_TREE_OBJECTID, \"csum\");\n\tif (ret)\n\t\treturn ret;\n\tfs_info->csum_root->track_dirty = 1;\n\n\tret = find_and_setup_root(root, fs_info, BTRFS_UUID_TREE_OBJECTID,\n\t\t\t\t fs_info->uuid_root);\n\tif (ret) {\n\t\tfree(fs_info->uuid_root);\n\t\tfs_info->uuid_root = NULL;\n\t} else {\n\t\tfs_info->uuid_root->track_dirty = 1;\n\t}\n\n\tret = find_and_setup_root(root, fs_info, BTRFS_QUOTA_TREE_OBJECTID,\n\t\t\t\t fs_info->quota_root);\n\tif (ret) {\n\t\tfree(fs_info->quota_root);\n\t\tfs_info->quota_root = NULL;\n\t} else {\n\t\tfs_info->quota_enabled = 1;\n\t}\n\n\tif (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) {\n\t\tret = find_and_setup_root(root, fs_info, BTRFS_FREE_SPACE_TREE_OBJECTID,\n\t\t\t\t\t fs_info->free_space_root);\n\t\tif (ret) {\n\t\t\tprintk(\"Couldn't read free space tree\\n\");\n\t\t\treturn -EIO;\n\t\t}\n\t\tfs_info->free_space_root->track_dirty = 1;\n\t}\n\n\tret = find_and_setup_log_root(root, fs_info, sb);\n\tif (ret) {\n\t\tprintk(\"Couldn't setup log root tree\\n\");\n\t\tif (!(flags & OPEN_CTREE_PARTIAL))\n\t\t\treturn -EIO;\n\t}\n\n\tfs_info->generation = generation;\n\tfs_info->last_trans_committed = generation;\n\tif (extent_buffer_uptodate(fs_info->extent_root->node) &&\n\t !(flags & OPEN_CTREE_NO_BLOCK_GROUPS)) {\n\t\tret = btrfs_read_block_groups(fs_info->tree_root);\n\t\t/*\n\t\t * If we don't find any blockgroups (ENOENT) we're either\n\t\t * restoring or creating the filesystem, where it's expected,\n\t\t * anything else is error\n\t\t */\n\t\tif (ret != -ENOENT)\n\t\t\treturn -EIO;\n\t}\n\n\tkey.objectid = BTRFS_FS_TREE_OBJECTID;\n\tkey.type = BTRFS_ROOT_ITEM_KEY;\n\tkey.offset = (u64)-1;\n\tfs_info->fs_root = btrfs_read_fs_root(fs_info, &key);\n\n\tif (IS_ERR(fs_info->fs_root))\n\t\treturn -EIO;\n\treturn 0;\n}\n\nvoid btrfs_release_all_roots(struct btrfs_fs_info *fs_info)\n{\n\tif (fs_info->free_space_root)\n\t\tfree_extent_buffer(fs_info->free_space_root->node);\n\tif (fs_info->quota_root)\n\t\tfree_extent_buffer(fs_info->quota_root->node);\n\tif (fs_info->csum_root)\n\t\tfree_extent_buffer(fs_info->csum_root->node);\n\tif (fs_info->dev_root)\n\t\tfree_extent_buffer(fs_info->dev_root->node);\n\tif (fs_info->extent_root)\n\t\tfree_extent_buffer(fs_info->extent_root->node);\n\tif (fs_info->tree_root)\n\t\tfree_extent_buffer(fs_info->tree_root->node);\n\tif (fs_info->log_root_tree)\n\t\tfree_extent_buffer(fs_info->log_root_tree->node);\n\tif (fs_info->chunk_root)\n\t\tfree_extent_buffer(fs_info->chunk_root->node);\n\tif (fs_info->uuid_root)\n\t\tfree_extent_buffer(fs_info->uuid_root->node);\n}\n\nstatic void free_map_lookup(struct cache_extent *ce)\n{\n\tstruct map_lookup *map;\n\n\tmap = container_of(ce, struct map_lookup, ce);\n\tkfree(map);\n}\n\nFREE_EXTENT_CACHE_BASED_TREE(mapping_cache, free_map_lookup);\n\nvoid btrfs_cleanup_all_caches(struct btrfs_fs_info *fs_info)\n{\n\twhile (!list_empty(&fs_info->recow_ebs)) {\n\t\tstruct extent_buffer *eb;\n\t\teb = list_first_entry(&fs_info->recow_ebs,\n\t\t\t\t struct extent_buffer, recow);\n\t\tlist_del_init(&eb->recow);\n\t\tfree_extent_buffer(eb);\n\t}\n\tfree_mapping_cache_tree(&fs_info->mapping_tree.cache_tree);\n\textent_io_tree_cleanup(&fs_info->extent_cache);\n\textent_io_tree_cleanup(&fs_info->free_space_cache);\n\textent_io_tree_cleanup(&fs_info->block_group_cache);\n\textent_io_tree_cleanup(&fs_info->pinned_extents);\n\textent_io_tree_cleanup(&fs_info->extent_ins);\n}\n\nint btrfs_scan_fs_devices(int fd, const char *path,\n\t\t\t struct btrfs_fs_devices **fs_devices,\n\t\t\t u64 sb_bytenr, unsigned sbflags,\n\t\t\t int skip_devices)\n{\n\tu64 total_devs;\n\tu64 dev_size;\n\toff_t seek_ret;\n\tint ret;\n\tif (!sb_bytenr)\n\t\tsb_bytenr = BTRFS_SUPER_INFO_OFFSET;\n\n\tseek_ret = lseek(fd, 0, SEEK_END);\n\tif (seek_ret < 0)\n\t\treturn -errno;\n\n\tdev_size = seek_ret;\n\tlseek(fd, 0, SEEK_SET);\n\tif (sb_bytenr > dev_size) {\n\t\terror(\"superblock bytenr %llu is larger than device size %llu\",\n\t\t\t\t(unsigned long long)sb_bytenr,\n\t\t\t\t(unsigned long long)dev_size);\n\t\treturn -EINVAL;\n\t}\n\n\tret = btrfs_scan_one_device(fd, path, fs_devices,\n\t\t\t\t &total_devs, sb_bytenr, sbflags);\n\tif (ret) {\n\t\tfprintf(stderr, \"No valid Btrfs found on %s\\n\", path);\n\t\treturn ret;\n\t}\n\n\tif (!skip_devices && total_devs != 1) {\n\t\tret = btrfs_scan_devices();\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\treturn 0;\n}\n\nint btrfs_setup_chunk_tree_and_device_map(struct btrfs_fs_info *fs_info,\n\t\t\t\t\t u64 chunk_root_bytenr)\n{\n\tstruct btrfs_super_block *sb = fs_info->super_copy;\n\tu64 generation;\n\tint ret;\n\n\tbtrfs_setup_root(fs_info->chunk_root, fs_info,\n\t\t\tBTRFS_CHUNK_TREE_OBJECTID);\n\n\tret = btrfs_read_sys_array(fs_info);\n\tif (ret)\n\t\treturn ret;\n\n\tgeneration = btrfs_super_chunk_root_generation(sb);\n\n\tif (chunk_root_bytenr && !IS_ALIGNED(chunk_root_bytenr,\n\t\t\t\t\t fs_info->sectorsize)) {\n\t\twarning(\"chunk_root_bytenr %llu is unaligned to %u, ignore it\",\n\t\t\tchunk_root_bytenr, fs_info->sectorsize);\n\t\tchunk_root_bytenr = 0;\n\t}\n\n\tif (!chunk_root_bytenr)\n\t\tchunk_root_bytenr = btrfs_super_chunk_root(sb);\n\telse\n\t\tgeneration = 0;\n\n\tfs_info->chunk_root->node = read_tree_block(fs_info,\n\t\t\t\t\t\t chunk_root_bytenr,\n\t\t\t\t\t\t generation);\n\tif (!extent_buffer_uptodate(fs_info->chunk_root->node)) {\n\t\tif (fs_info->ignore_chunk_tree_error) {\n\t\t\twarning(\"cannot read chunk root, continue anyway\");\n\t\t\tfs_info->chunk_root = NULL;\n\t\t\treturn 0;\n\t\t} else {\n\t\t\terror(\"cannot read chunk root\");\n\t\t\treturn -EIO;\n\t\t}\n\t}\n\n\tif (!(btrfs_super_flags(sb) & BTRFS_SUPER_FLAG_METADUMP)) {\n\t\tret = btrfs_read_chunk_tree(fs_info);\n\t\tif (ret) {\n\t\t\tfprintf(stderr, \"Couldn't read chunk tree\\n\");\n\t\t\treturn ret;\n\t\t}\n\t}\n\treturn 0;\n}\n\nstatic struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,\n\t\t\t\t\t u64 sb_bytenr,\n\t\t\t\t\t u64 root_tree_bytenr,\n\t\t\t\t\t u64 chunk_root_bytenr,\n\t\t\t\t\t unsigned flags)\n{\n\tstruct btrfs_fs_info *fs_info;\n\tstruct btrfs_super_block *disk_super;\n\tstruct btrfs_fs_devices *fs_devices = NULL;\n\tstruct extent_buffer *eb;\n\tint ret;\n\tint oflags;\n\tunsigned sbflags = SBREAD_DEFAULT;\n\n\tif (sb_bytenr == 0)\n\t\tsb_bytenr = BTRFS_SUPER_INFO_OFFSET;\n\n\t/* try to drop all the caches */\n\tif (posix_fadvise(fp, 0, 0, POSIX_FADV_DONTNEED))\n\t\tfprintf(stderr, \"Warning, could not drop caches\\n\");\n\n\tfs_info = btrfs_new_fs_info(flags & OPEN_CTREE_WRITES, sb_bytenr);\n\tif (!fs_info) {\n\t\tfprintf(stderr, \"Failed to allocate memory for fs_info\\n\");\n\t\treturn NULL;\n\t}\n\tif (flags & OPEN_CTREE_RESTORE)\n\t\tfs_info->on_restoring = 1;\n\tif (flags & OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS)\n\t\tfs_info->suppress_check_block_errors = 1;\n\tif (flags & OPEN_CTREE_IGNORE_FSID_MISMATCH)\n\t\tfs_info->ignore_fsid_mismatch = 1;\n\tif (flags & OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR)\n\t\tfs_info->ignore_chunk_tree_error = 1;\n\tif (flags & OPEN_CTREE_DONT_PRINT_FILENAME)\n\t\tfs_info->dont_print_filename = 1;\n\n\tif ((flags & OPEN_CTREE_RECOVER_SUPER)\n\t && (flags & OPEN_CTREE_TEMPORARY_SUPER)) {\n\t\tfprintf(stderr,\n\t\"cannot open a filesystem with temporary super block for recovery\");\n\t\tgoto out;\n\t}\n\n\tif (flags & OPEN_CTREE_TEMPORARY_SUPER)\n\t\tsbflags = SBREAD_TEMPORARY;\n\n\tif (flags & OPEN_CTREE_IGNORE_FSID_MISMATCH)\n\t\tsbflags |= SBREAD_IGNORE_FSID_MISMATCH;\n\n\tret = btrfs_scan_fs_devices(fp, path, &fs_devices, sb_bytenr, sbflags,\n\t\t\t(flags & OPEN_CTREE_NO_DEVICES));\n\tif (ret)\n\t\tgoto out;\n\n\tfs_info->fs_devices = fs_devices;\n\tif (flags & OPEN_CTREE_WRITES)\n\t\toflags = O_RDWR;\n\telse\n\t\toflags = O_RDONLY;\n\n\tif (flags & OPEN_CTREE_EXCLUSIVE)\n\t\toflags |= O_EXCL;\n\n\tret = btrfs_open_devices(fs_devices, oflags);\n\tif (ret)\n\t\tgoto out;\n\n\tdisk_super = fs_info->super_copy;\n\tif (flags & OPEN_CTREE_RECOVER_SUPER)\n\t\tret = btrfs_read_dev_super(fs_devices->latest_bdev, disk_super,\n\t\t\t\tsb_bytenr, SBREAD_RECOVER);\n\telse\n\t\tret = btrfs_read_dev_super(fp, disk_super, sb_bytenr,\n\t\t\t\tsbflags);\n\tif (ret) {\n\t\tprintk(\"No valid btrfs found\\n\");\n\t\tgoto out_devices;\n\t}\n\n\tif (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_CHANGING_FSID &&\n\t !fs_info->ignore_fsid_mismatch) {\n\t\tfprintf(stderr, \"ERROR: Filesystem UUID change in progress\\n\");\n\t\tgoto out_devices;\n\t}\n\n\tASSERT(!memcmp(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE));\n\tASSERT(!memcmp(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE));\n\tif (btrfs_fs_incompat(fs_info, METADATA_UUID))\n\t\tASSERT(!memcmp(disk_super->metadata_uuid,\n\t\t\t fs_devices->metadata_uuid, BTRFS_FSID_SIZE));\n\n\tfs_info->sectorsize = btrfs_super_sectorsize(disk_super);\n\tfs_info->nodesize = btrfs_super_nodesize(disk_super);\n\tfs_info->stripesize = btrfs_super_stripesize(disk_super);\n\n\tret = btrfs_check_fs_compatibility(fs_info->super_copy, flags);\n\tif (ret)\n\t\tgoto out_devices;\n\n\tret = btrfs_setup_chunk_tree_and_device_map(fs_info, chunk_root_bytenr);\n\tif (ret)\n\t\tgoto out_chunk;\n\n\t/* Chunk tree root is unable to read, return directly */\n\tif (!fs_info->chunk_root)\n\t\treturn fs_info;\n\n\teb = fs_info->chunk_root->node;\n\tread_extent_buffer(eb, fs_info->chunk_tree_uuid,\n\t\t\t btrfs_header_chunk_tree_uuid(eb),\n\t\t\t BTRFS_UUID_SIZE);\n\n\tret = btrfs_setup_all_roots(fs_info, root_tree_bytenr, flags);\n\tif (ret && !(flags & __OPEN_CTREE_RETURN_CHUNK_ROOT) &&\n\t !fs_info->ignore_chunk_tree_error)\n\t\tgoto out_chunk;\n\n\treturn fs_info;\n\nout_chunk:\n\tbtrfs_release_all_roots(fs_info);\n\tbtrfs_cleanup_all_caches(fs_info);\nout_devices:\n\tbtrfs_close_devices(fs_devices);\nout:\n\tbtrfs_free_fs_info(fs_info);\n\treturn NULL;\n}\n\nstruct btrfs_fs_info *open_ctree_fs_info(const char *filename,\n\t\t\t\t\t u64 sb_bytenr, u64 root_tree_bytenr,\n\t\t\t\t\t u64 chunk_root_bytenr,\n\t\t\t\t\t unsigned flags)\n{\n\tint fp;\n\tint ret;\n\tstruct btrfs_fs_info *info;\n\tint oflags = O_RDWR;\n\tstruct stat st;\n\n\tret = stat(filename, &st);\n\tif (ret < 0) {\n\t\terror(\"cannot stat '%s': %m\", filename);\n\t\treturn NULL;\n\t}\n\tif (!(((st.st_mode & S_IFMT) == S_IFREG) || ((st.st_mode & S_IFMT) == S_IFBLK))) {\n\t\terror(\"not a regular file or block device: %s\", filename);\n\t\treturn NULL;\n\t}\n\n\tif (!(flags & OPEN_CTREE_WRITES))\n\t\toflags = O_RDONLY;\n\n\tfp = open(filename, oflags);\n\tif (fp < 0) {\n\t\terror(\"cannot open '%s': %m\", filename);\n\t\treturn NULL;\n\t}\n\tinfo = __open_ctree_fd(fp, filename, sb_bytenr, root_tree_bytenr,\n\t\t\t chunk_root_bytenr, flags);\n\tclose(fp);\n\treturn info;\n}\n\nstruct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr,\n\t\t\t unsigned flags)\n{\n\tstruct btrfs_fs_info *info;\n\n\t/* This flags may not return fs_info with any valid root */\n\tBUG_ON(flags & OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR);\n\tinfo = open_ctree_fs_info(filename, sb_bytenr, 0, 0, flags);\n\tif (!info)\n\t\treturn NULL;\n\tif (flags & __OPEN_CTREE_RETURN_CHUNK_ROOT)\n\t\treturn info->chunk_root;\n\treturn info->fs_root;\n}\n\nstruct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,\n\t\t\t\t unsigned flags)\n{\n\tstruct btrfs_fs_info *info;\n\n\t/* This flags may not return fs_info with any valid root */\n\tif (flags & OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR) {\n\t\terror(\"invalid open_ctree flags: 0x%llx\",\n\t\t\t\t(unsigned long long)flags);\n\t\treturn NULL;\n\t}\n\tinfo = __open_ctree_fd(fp, path, sb_bytenr, 0, 0, flags);\n\tif (!info)\n\t\treturn NULL;\n\tif (flags & __OPEN_CTREE_RETURN_CHUNK_ROOT)\n\t\treturn info->chunk_root;\n\treturn info->fs_root;\n}\n\n/*\n * Check if the super is valid:\n * - nodesize/sectorsize - minimum, maximum, alignment\n * - tree block starts - alignment\n * - number of devices - something sane\n * - sys array size - maximum\n */\nint btrfs_check_super(struct btrfs_super_block *sb, unsigned sbflags)\n{\n\tu8 result[BTRFS_CSUM_SIZE];\n\tu16 csum_type;\n\tint csum_size;\n\tu8 *metadata_uuid;\n\n\tif (btrfs_super_magic(sb) != BTRFS_MAGIC) {\n\t\tif (btrfs_super_magic(sb) == BTRFS_MAGIC_TEMPORARY) {\n\t\t\tif (!(sbflags & SBREAD_TEMPORARY)) {\n\t\t\t\terror(\"superblock magic doesn't match\");\n\t\t\t\treturn -EIO;\n\t\t\t}\n\t\t}\n\t}\n\n\tcsum_type = btrfs_super_csum_type(sb);\n\tif (csum_type >= btrfs_super_num_csums()) {\n\t\terror(\"unsupported checksum algorithm %u\", csum_type);\n\t\treturn -EIO;\n\t}\n\tcsum_size = btrfs_super_csum_size(sb);\n\n\tbtrfs_csum_data(csum_type, (u8 *)sb + BTRFS_CSUM_SIZE,\n\t\t\tresult, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);\n\n\tif (memcmp(result, sb->csum, csum_size)) {\n\t\terror(\"superblock checksum mismatch\");\n\t\treturn -EIO;\n\t}\n\tif (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) {\n\t\terror(\"tree_root level too big: %d >= %d\",\n\t\t\tbtrfs_super_root_level(sb), BTRFS_MAX_LEVEL);\n\t\tgoto error_out;\n\t}\n\tif (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) {\n\t\terror(\"chunk_root level too big: %d >= %d\",\n\t\t\tbtrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL);\n\t\tgoto error_out;\n\t}\n\tif (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) {\n\t\terror(\"log_root level too big: %d >= %d\",\n\t\t\tbtrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL);\n\t\tgoto error_out;\n\t}\n\n\tif (!IS_ALIGNED(btrfs_super_root(sb), 4096)) {\n\t\terror(\"tree_root block unaligned: %llu\", btrfs_super_root(sb));\n\t\tgoto error_out;\n\t}\n\tif (!IS_ALIGNED(btrfs_super_chunk_root(sb), 4096)) {\n\t\terror(\"chunk_root block unaligned: %llu\",\n\t\t\tbtrfs_super_chunk_root(sb));\n\t\tgoto error_out;\n\t}\n\tif (!IS_ALIGNED(btrfs_super_log_root(sb), 4096)) {\n\t\terror(\"log_root block unaligned: %llu\",\n\t\t\tbtrfs_super_log_root(sb));\n\t\tgoto error_out;\n\t}\n\tif (btrfs_super_nodesize(sb) < 4096) {\n\t\terror(\"nodesize too small: %u < 4096\",\n\t\t\tbtrfs_super_nodesize(sb));\n\t\tgoto error_out;\n\t}\n\tif (!IS_ALIGNED(btrfs_super_nodesize(sb), 4096)) {\n\t\terror(\"nodesize unaligned: %u\", btrfs_super_nodesize(sb));\n\t\tgoto error_out;\n\t}\n\tif (btrfs_super_sectorsize(sb) < 4096) {\n\t\terror(\"sectorsize too small: %u < 4096\",\n\t\t\tbtrfs_super_sectorsize(sb));\n\t\tgoto error_out;\n\t}\n\tif (!IS_ALIGNED(btrfs_super_sectorsize(sb), 4096)) {\n\t\terror(\"sectorsize unaligned: %u\", btrfs_super_sectorsize(sb));\n\t\tgoto error_out;\n\t}\n\tif (btrfs_super_total_bytes(sb) == 0) {\n\t\terror(\"invalid total_bytes 0\");\n\t\tgoto error_out;\n\t}\n\tif (btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb)) {\n\t\terror(\"invalid bytes_used %llu\", btrfs_super_bytes_used(sb));\n\t\tgoto error_out;\n\t}\n\tif ((btrfs_super_stripesize(sb) != 4096)\n\t\t&& (btrfs_super_stripesize(sb) != btrfs_super_sectorsize(sb))) {\n\t\terror(\"invalid stripesize %u\", btrfs_super_stripesize(sb));\n\t\tgoto error_out;\n\t}\n\n\tif (btrfs_super_incompat_flags(sb) & BTRFS_FEATURE_INCOMPAT_METADATA_UUID)\n\t\tmetadata_uuid = sb->metadata_uuid;\n\telse\n\t\tmetadata_uuid = sb->fsid;\n\n\tif (memcmp(metadata_uuid, sb->dev_item.fsid, BTRFS_FSID_SIZE) != 0) {\n\t\tchar fsid[BTRFS_UUID_UNPARSED_SIZE];\n\t\tchar dev_fsid[BTRFS_UUID_UNPARSED_SIZE];\n\n\t\tuuid_unparse(sb->metadata_uuid, fsid);\n\t\tuuid_unparse(sb->dev_item.fsid, dev_fsid);\n\t\tif (sbflags & SBREAD_IGNORE_FSID_MISMATCH) {\n\t\t\twarning(\"ignored: dev_item fsid mismatch: %s != %s\",\n\t\t\t\t\tdev_fsid, fsid);\n\t\t} else {\n\t\t\terror(\"dev_item UUID does not match fsid: %s != %s\",\n\t\t\t\t\tdev_fsid, fsid);\n\t\t\tgoto error_out;\n\t\t}\n\t}\n\n\t/*\n\t * Hint to catch really bogus numbers, bitflips or so\n\t */\n\tif (btrfs_super_num_devices(sb) > (1UL << 31)) {\n\t\twarning(\"suspicious number of devices: %llu\",\n\t\t\tbtrfs_super_num_devices(sb));\n\t}\n\n\tif (btrfs_super_num_devices(sb) == 0) {\n\t\terror(\"number of devices is 0\");\n\t\tgoto error_out;\n\t}\n\n\t/*\n\t * Obvious sys_chunk_array corruptions, it must hold at least one key\n\t * and one chunk\n\t */\n\tif (btrfs_super_sys_array_size(sb) > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) {\n\t\terror(\"system chunk array too big %u > %u\",\n\t\t btrfs_super_sys_array_size(sb),\n\t\t BTRFS_SYSTEM_CHUNK_ARRAY_SIZE);\n\t\tgoto error_out;\n\t}\n\tif (btrfs_super_sys_array_size(sb) < sizeof(struct btrfs_disk_key)\n\t\t\t+ sizeof(struct btrfs_chunk)) {\n\t\terror(\"system chunk array too small %u < %zu\",\n\t\t btrfs_super_sys_array_size(sb),\n\t\t sizeof(struct btrfs_disk_key) +\n\t\t sizeof(struct btrfs_chunk));\n\t\tgoto error_out;\n\t}\n\n\treturn 0;\n\nerror_out:\n\terror(\"superblock checksum matches but it has invalid members\");\n\treturn -EIO;\n}\n\n/*\n * btrfs_read_dev_super - read a valid superblock from a block device\n * @fd:\t\tfile descriptor of the device\n * @sb:\t\tbuffer where the superblock is going to be read in\n * @sb_bytenr: offset of the particular superblock copy we want\n * @sbflags:\tflags controlling how the superblock is read\n *\n * This function is used by various btrfs commands to obtain a valid superblock.\n *\n * It's mode of operation is controlled by the @sb_bytenr and @sbdflags\n * parameters. If SBREAD_RECOVER flag is set and @sb_bytenr is\n * BTRFS_SUPER_INFO_OFFSET then the function reads all 3 superblock copies and\n * returns the newest one. If SBREAD_RECOVER is not set then only a single\n * copy is read, which one is decided by @sb_bytenr. If @sb_bytenr !=\n * BTRFS_SUPER_INFO_OFFSET then the @sbflags is effectively ignored and only a\n * single copy is read.\n */\nint btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr,\n\t\t\t unsigned sbflags)\n{\n\tu8 fsid[BTRFS_FSID_SIZE];\n\tu8 metadata_uuid[BTRFS_FSID_SIZE];\n\tint fsid_is_initialized = 0;\n\tchar tmp[BTRFS_SUPER_INFO_SIZE];\n\tstruct btrfs_super_block *buf = (struct btrfs_super_block *)tmp;\n\tint i;\n\tint ret;\n\tint max_super = sbflags & SBREAD_RECOVER ? BTRFS_SUPER_MIRROR_MAX : 1;\n\tu64 transid = 0;\n\tbool metadata_uuid_set = false;\n\tu64 bytenr;\n\n\tif (sb_bytenr != BTRFS_SUPER_INFO_OFFSET) {\n\t\tret = pread64(fd, buf, BTRFS_SUPER_INFO_SIZE, sb_bytenr);\n\t\t/* real error */\n\t\tif (ret < 0)\n\t\t\treturn -errno;\n\n\t\t/* Not large enough sb, return -ENOENT instead of normal -EIO */\n\t\tif (ret < BTRFS_SUPER_INFO_SIZE)\n\t\t\treturn -ENOENT;\n\n\t\tif (btrfs_super_bytenr(buf) != sb_bytenr)\n\t\t\treturn -EIO;\n\n\t\tret = btrfs_check_super(buf, sbflags);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t\tmemcpy(sb, buf, BTRFS_SUPER_INFO_SIZE);\n\t\treturn 0;\n\t}\n\n\t/*\n\t* we would like to check all the supers, but that would make\n\t* a btrfs mount succeed after a mkfs from a different FS.\n\t* So, we need to add a special mount option to scan for\n\t* later supers, using BTRFS_SUPER_MIRROR_MAX instead\n\t*/\n\n\tfor (i = 0; i < max_super; i++) {\n\t\tbytenr = btrfs_sb_offset(i);\n\t\tret = pread64(fd, buf, BTRFS_SUPER_INFO_SIZE, bytenr);\n\t\tif (ret < BTRFS_SUPER_INFO_SIZE)\n\t\t\tbreak;\n\n\t\tif (btrfs_super_bytenr(buf) != bytenr )\n\t\t\tcontinue;\n\t\t/* if magic is NULL, the device was removed */\n\t\tif (btrfs_super_magic(buf) == 0 && i == 0)\n\t\t\tbreak;\n\t\tif (btrfs_check_super(buf, sbflags))\n\t\t\tcontinue;\n\n\t\tif (!fsid_is_initialized) {\n\t\t\tif (btrfs_super_incompat_flags(buf) &\n\t\t\t BTRFS_FEATURE_INCOMPAT_METADATA_UUID) {\n\t\t\t\tmetadata_uuid_set = true;\n\t\t\t\tmemcpy(metadata_uuid, buf->metadata_uuid,\n\t\t\t\t sizeof(metadata_uuid));\n\t\t\t}\n\t\t\tmemcpy(fsid, buf->fsid, sizeof(fsid));\n\t\t\tfsid_is_initialized = 1;\n\t\t} else if (memcmp(fsid, buf->fsid, sizeof(fsid)) ||\n\t\t\t (metadata_uuid_set && memcmp(metadata_uuid,\n\t\t\t\t\t\t\tbuf->metadata_uuid,\n\t\t\t\t\t\t\tsizeof(metadata_uuid)))) {\n\t\t\t/*\n\t\t\t * the superblocks (the original one and\n\t\t\t * its backups) contain data of different\n\t\t\t * filesystems -> the super cannot be trusted\n\t\t\t */\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (btrfs_super_generation(buf) > transid) {\n\t\t\tmemcpy(sb, buf, BTRFS_SUPER_INFO_SIZE);\n\t\t\ttransid = btrfs_super_generation(buf);\n\t\t}\n\t}\n\n\treturn transid > 0 ? 0 : -1;\n}\n\nstatic int write_dev_supers(struct btrfs_fs_info *fs_info,\n\t\t\t struct btrfs_super_block *sb,\n\t\t\t struct btrfs_device *device)\n{\n\tu64 bytenr;\n\tu8 result[BTRFS_CSUM_SIZE];\n\tint i, ret;\n\tu16 csum_type = btrfs_super_csum_type(sb);\n\n\t/*\n\t * We need to write super block after all metadata written.\n\t * This is the equivalent of kernel pre-flush for FUA.\n\t */\n\tret = fsync(device->fd);\n\tif (ret < 0) {\n\t\terror(\n\t\t\"failed to write super block for devid %llu: flush error: %m\",\n\t\t\tdevice->devid);\n\t\treturn -errno;\n\t}\n\tif (fs_info->super_bytenr != BTRFS_SUPER_INFO_OFFSET) {\n\t\tbtrfs_set_super_bytenr(sb, fs_info->super_bytenr);\n\t\tbtrfs_csum_data(csum_type, (u8 *)sb + BTRFS_CSUM_SIZE, result,\n\t\t\t\tBTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);\n\t\tmemcpy(&sb->csum[0], result, BTRFS_CSUM_SIZE);\n\n\t\t/*\n\t\t * super_copy is BTRFS_SUPER_INFO_SIZE bytes and is\n\t\t * zero filled, we can use it directly\n\t\t */\n\t\tret = pwrite64(device->fd, fs_info->super_copy,\n\t\t\t\tBTRFS_SUPER_INFO_SIZE,\n\t\t\t\tfs_info->super_bytenr);\n\t\tif (ret != BTRFS_SUPER_INFO_SIZE) {\n\t\t\terrno = EIO;\n\t\t\terror(\n\t\t\"failed to write super block for devid %llu: write error: %m\",\n\t\t\t\tdevice->devid);\n\t\t\treturn -EIO;\n\t\t}\n\t\tret = fsync(device->fd);\n\t\tif (ret < 0) {\n\t\t\terror(\n\t\t\"failed to write super block for devid %llu: flush error: %m\",\n\t\t\t\tdevice->devid);\n\t\t\treturn -errno;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tfor (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {\n\t\tbytenr = btrfs_sb_offset(i);\n\t\tif (bytenr + BTRFS_SUPER_INFO_SIZE > device->total_bytes)\n\t\t\tbreak;\n\n\t\tbtrfs_set_super_bytenr(sb, bytenr);\n\n\t\tbtrfs_csum_data(csum_type, (u8 *)sb + BTRFS_CSUM_SIZE, result,\n\t\t\t\t BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);\n\t\tmemcpy(&sb->csum[0], result, BTRFS_CSUM_SIZE);\n\n\t\t/*\n\t\t * super_copy is BTRFS_SUPER_INFO_SIZE bytes and is\n\t\t * zero filled, we can use it directly\n\t\t */\n\t\tret = pwrite64(device->fd, fs_info->super_copy,\n\t\t\t\tBTRFS_SUPER_INFO_SIZE, bytenr);\n\t\tif (ret != BTRFS_SUPER_INFO_SIZE) {\n\t\t\terrno = EIO;\n\t\t\terror(\n\t\t\"failed to write super block for devid %llu: write error: %m\",\n\t\t\t\tdevice->devid);\n\t\t\treturn -errno;\n\t\t}\n\t\t/*\n\t\t * Flush after the primary sb write, this is the equivalent of\n\t\t * kernel post-flush for FUA write.\n\t\t */\n\t\tif (i == 0) {\n\t\t\tret = fsync(device->fd);\n\t\t\tif (ret < 0) {\n\t\t\t\terror(\n\t\t\"failed to write super block for devid %llu: flush error: %m\",\n\t\t\t\t\tdevice->devid);\n\t\t\t\treturn -errno;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n * copy all the root pointers into the super backup array.\n * this will bump the backup pointer by one when it is\n * done\n */\nstatic void backup_super_roots(struct btrfs_fs_info *info)\n{\n\tstruct btrfs_root_backup *root_backup;\n\tint next_backup;\n\tint last_backup;\n\n\tlast_backup = find_best_backup_root(info->super_copy);\n\tnext_backup = (last_backup + 1) % BTRFS_NUM_BACKUP_ROOTS;\n\n\t/* just overwrite the last backup if we're at the same generation */\n\troot_backup = info->super_copy->super_roots + last_backup;\n\tif (btrfs_backup_tree_root_gen(root_backup) ==\n\t btrfs_header_generation(info->tree_root->node))\n\t\tnext_backup = last_backup;\n\n\troot_backup = info->super_copy->super_roots + next_backup;\n\n\t/*\n\t * make sure all of our padding and empty slots get zero filled\n\t * regardless of which ones we use today\n\t */\n\tmemset(root_backup, 0, sizeof(*root_backup));\n\tbtrfs_set_backup_tree_root(root_backup, info->tree_root->node->start);\n\tbtrfs_set_backup_tree_root_gen(root_backup,\n\t\t\t btrfs_header_generation(info->tree_root->node));\n\tbtrfs_set_backup_tree_root_level(root_backup,\n\t\t\t btrfs_header_level(info->tree_root->node));\n\n\tbtrfs_set_backup_chunk_root(root_backup, info->chunk_root->node->start);\n\tbtrfs_set_backup_chunk_root_gen(root_backup,\n\t\t\t btrfs_header_generation(info->chunk_root->node));\n\tbtrfs_set_backup_chunk_root_level(root_backup,\n\t\t\t btrfs_header_level(info->chunk_root->node));\n\n\tbtrfs_set_backup_extent_root(root_backup, info->extent_root->node->start);\n\tbtrfs_set_backup_extent_root_gen(root_backup,\n\t\t\t btrfs_header_generation(info->extent_root->node));\n\tbtrfs_set_backup_extent_root_level(root_backup,\n\t\t\t btrfs_header_level(info->extent_root->node));\n\t/*\n\t * we might commit during log recovery, which happens before we set\n\t * the fs_root. Make sure it is valid before we fill it in.\n\t */\n\tif (info->fs_root && info->fs_root->node) {\n\t\tbtrfs_set_backup_fs_root(root_backup,\n\t\t\t\t\t info->fs_root->node->start);\n\t\tbtrfs_set_backup_fs_root_gen(root_backup,\n\t\t\t btrfs_header_generation(info->fs_root->node));\n\t\tbtrfs_set_backup_fs_root_level(root_backup,\n\t\t\t btrfs_header_level(info->fs_root->node));\n\t}\n\n\tbtrfs_set_backup_dev_root(root_backup, info->dev_root->node->start);\n\tbtrfs_set_backup_dev_root_gen(root_backup,\n\t\t\t btrfs_header_generation(info->dev_root->node));\n\tbtrfs_set_backup_dev_root_level(root_backup,\n\t\t\t\t btrfs_header_level(info->dev_root->node));\n\n\tbtrfs_set_backup_csum_root(root_backup, info->csum_root->node->start);\n\tbtrfs_set_backup_csum_root_gen(root_backup,\n\t\t\t btrfs_header_generation(info->csum_root->node));\n\tbtrfs_set_backup_csum_root_level(root_backup,\n\t\t\t btrfs_header_level(info->csum_root->node));\n\n\tbtrfs_set_backup_total_bytes(root_backup,\n\t\t\t btrfs_super_total_bytes(info->super_copy));\n\tbtrfs_set_backup_bytes_used(root_backup,\n\t\t\t btrfs_super_bytes_used(info->super_copy));\n\tbtrfs_set_backup_num_devices(root_backup,\n\t\t\t btrfs_super_num_devices(info->super_copy));\n};\n\nint write_all_supers(struct btrfs_fs_info *fs_info)\n{\n\tstruct list_head *head = &fs_info->fs_devices->devices;\n\tstruct btrfs_device *dev;\n\tstruct btrfs_super_block *sb;\n\tstruct btrfs_dev_item *dev_item;\n\tint ret;\n\tu64 flags;\n\n\tbackup_super_roots(fs_info);\n\tsb = fs_info->super_copy;\n\tdev_item = &sb->dev_item;\n\tlist_for_each_entry(dev, head, dev_list) {\n\t\tif (!dev->writeable)\n\t\t\tcontinue;\n\n\t\tbtrfs_set_stack_device_generation(dev_item, 0);\n\t\tbtrfs_set_stack_device_type(dev_item, dev->type);\n\t\tbtrfs_set_stack_device_id(dev_item, dev->devid);\n\t\tbtrfs_set_stack_device_total_bytes(dev_item, dev->total_bytes);\n\t\tbtrfs_set_stack_device_bytes_used(dev_item, dev->bytes_used);\n\t\tbtrfs_set_stack_device_io_align(dev_item, dev->io_align);\n\t\tbtrfs_set_stack_device_io_width(dev_item, dev->io_width);\n\t\tbtrfs_set_stack_device_sector_size(dev_item, dev->sector_size);\n\t\tmemcpy(dev_item->uuid, dev->uuid, BTRFS_UUID_SIZE);\n\t\tmemcpy(dev_item->fsid, fs_info->fs_devices->metadata_uuid,\n\t\t BTRFS_FSID_SIZE);\n\n\t\tflags = btrfs_super_flags(sb);\n\t\tbtrfs_set_super_flags(sb, flags | BTRFS_HEADER_FLAG_WRITTEN);\n\n\t\tret = write_dev_supers(fs_info, sb, dev);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\treturn 0;\n}\n\nint write_ctree_super(struct btrfs_trans_handle *trans)\n{\n\tint ret;\n\tstruct btrfs_fs_info *fs_info = trans->fs_info;\n\tstruct btrfs_root *tree_root = fs_info->tree_root;\n\tstruct btrfs_root *chunk_root = fs_info->chunk_root;\n\n\tif (fs_info->readonly)\n\t\treturn 0;\n\n\tbtrfs_set_super_generation(fs_info->super_copy,\n\t\t\t\t trans->transid);\n\tbtrfs_set_super_root(fs_info->super_copy,\n\t\t\t tree_root->node->start);\n\tbtrfs_set_super_root_level(fs_info->super_copy,\n\t\t\t\t btrfs_header_level(tree_root->node));\n\tbtrfs_set_super_chunk_root(fs_info->super_copy,\n\t\t\t\t chunk_root->node->start);\n\tbtrfs_set_super_chunk_root_level(fs_info->super_copy,\n\t\t\t\t\t btrfs_header_level(chunk_root->node));\n\tbtrfs_set_super_chunk_root_generation(fs_info->super_copy,\n\t\t\t\tbtrfs_header_generation(chunk_root->node));\n\n\tret = write_all_supers(fs_info);\n\tif (ret)\n\t\tfprintf(stderr, \"failed to write new super block err %d\\n\", ret);\n\treturn ret;\n}\n\nint close_ctree_fs_info(struct btrfs_fs_info *fs_info)\n{\n\tint ret;\n\tint err = 0;\n\tstruct btrfs_trans_handle *trans;\n\tstruct btrfs_root *root = fs_info->tree_root;\n\n\tif (fs_info->last_trans_committed !=\n\t fs_info->generation) {\n\t\tBUG_ON(!root);\n\t\ttrans = btrfs_start_transaction(root, 1);\n\t\tif (IS_ERR(trans)) {\n\t\t\terr = PTR_ERR(trans);\n\t\t\tgoto skip_commit;\n\t\t}\n\t\tbtrfs_commit_transaction(trans, root);\n\t\ttrans = btrfs_start_transaction(root, 1);\n\t\tBUG_ON(IS_ERR(trans));\n\t\tret = commit_tree_roots(trans, fs_info);\n\t\tBUG_ON(ret);\n\t\tret = __commit_transaction(trans, root);\n\t\tBUG_ON(ret);\n\t\tret = write_ctree_super(trans);\n\t\tkfree(trans);\n\t\tif (ret) {\n\t\t\terr = ret;\n\t\t\tgoto skip_commit;\n\t\t}\n\t}\n\n\tif (fs_info->finalize_on_close) {\n\t\tbtrfs_set_super_magic(fs_info->super_copy, BTRFS_MAGIC);\n\t\troot->fs_info->finalize_on_close = 0;\n\t\tret = write_all_supers(fs_info);\n\t\tif (ret)\n\t\t\tfprintf(stderr,\n\t\t\t\t\"failed to write new super block err %d\\n\", ret);\n\t}\n\nskip_commit:\n\tbtrfs_free_block_groups(fs_info);\n\n\tfree_fs_roots_tree(&fs_info->fs_root_tree);\n\n\tbtrfs_release_all_roots(fs_info);\n\tret = btrfs_close_devices(fs_info->fs_devices);\n\tbtrfs_cleanup_all_caches(fs_info);\n\tbtrfs_free_fs_info(fs_info);\n\tif (!err)\n\t\terr = ret;\n\treturn err;\n}\n\nint clean_tree_block(struct extent_buffer *eb)\n{\n\treturn clear_extent_buffer_dirty(eb);\n}\n\nvoid btrfs_mark_buffer_dirty(struct extent_buffer *eb)\n{\n\tset_extent_buffer_dirty(eb);\n}\n\nint btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid)\n{\n\tint ret;\n\n\tret = extent_buffer_uptodate(buf);\n\tif (!ret)\n\t\treturn ret;\n\n\tret = verify_parent_transid(buf->tree, buf, parent_transid, 1);\n\treturn !ret;\n}\n\nint btrfs_set_buffer_uptodate(struct extent_buffer *eb)\n{\n\treturn set_extent_buffer_uptodate(eb);\n}\n\nstruct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,\n\t\t\t\t struct btrfs_fs_info *fs_info,\n\t\t\t\t u64 objectid)\n{\n\tstruct extent_buffer *leaf;\n\tstruct btrfs_root *tree_root = fs_info->tree_root;\n\tstruct btrfs_root *root;\n\tstruct btrfs_key key;\n\tint ret = 0;\n\n\troot = kzalloc(sizeof(*root), GFP_KERNEL);\n\tif (!root)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tbtrfs_setup_root(root, fs_info, objectid);\n\troot->root_key.objectid = objectid;\n\troot->root_key.type = BTRFS_ROOT_ITEM_KEY;\n\troot->root_key.offset = 0;\n\n\tleaf = btrfs_alloc_free_block(trans, root, fs_info->nodesize, objectid,\n\t\t\tNULL, 0, 0, 0);\n\tif (IS_ERR(leaf)) {\n\t\tret = PTR_ERR(leaf);\n\t\tleaf = NULL;\n\t\tgoto fail;\n\t}\n\n\tmemset_extent_buffer(leaf, 0, 0, sizeof(struct btrfs_header));\n\tbtrfs_set_header_bytenr(leaf, leaf->start);\n\tbtrfs_set_header_generation(leaf, trans->transid);\n\tbtrfs_set_header_backref_rev(leaf, BTRFS_MIXED_BACKREF_REV);\n\tbtrfs_set_header_owner(leaf, objectid);\n\troot->node = leaf;\n\twrite_extent_buffer(leaf, fs_info->fs_devices->metadata_uuid,\n\t\t\t btrfs_header_fsid(), BTRFS_FSID_SIZE);\n\twrite_extent_buffer(leaf, fs_info->chunk_tree_uuid,\n\t\t\t btrfs_header_chunk_tree_uuid(leaf),\n\t\t\t BTRFS_UUID_SIZE);\n\tbtrfs_mark_buffer_dirty(leaf);\n\n\textent_buffer_get(root->node);\n\troot->commit_root = root->node;\n\troot->track_dirty = 1;\n\n\troot->root_item.flags = 0;\n\troot->root_item.byte_limit = 0;\n\tbtrfs_set_root_bytenr(&root->root_item, leaf->start);\n\tbtrfs_set_root_generation(&root->root_item, trans->transid);\n\tbtrfs_set_root_level(&root->root_item, 0);\n\tbtrfs_set_root_refs(&root->root_item, 1);\n\tbtrfs_set_root_used(&root->root_item, leaf->len);\n\tbtrfs_set_root_last_snapshot(&root->root_item, 0);\n\tbtrfs_set_root_dirid(&root->root_item, 0);\n\tmemset(root->root_item.uuid, 0, BTRFS_UUID_SIZE);\n\troot->root_item.drop_level = 0;\n\n\tkey.objectid = objectid;\n\tkey.type = BTRFS_ROOT_ITEM_KEY;\n\tkey.offset = 0;\n\tret = btrfs_insert_root(trans, tree_root, &key, &root->root_item);\n\tif (ret)\n\t\tgoto fail;\n\n\treturn root;\n\nfail:\n\tif (leaf)\n\t\tfree_extent_buffer(leaf);\n\n\tkfree(root);\n\treturn ERR_PTR(ret);\n}\n"}}}]
Sat 16 Nov 2019 08:10:28 PM CST:[{"response":{"data":{"path":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","__data__":"vim-lsp","filetype":"c","server_name":"clangd"},"message":"textDocument/open sent"}}]
Sat 16 Nov 2019 08:10:28 PM CST:[{"response":{"data":{"path":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","__data__":"vim-lsp","server_name":"clangd"},"message":"not dirty"}}]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["I[20:10:28.410] clangd version 9.0.0 (tags/RELEASE_900/final)","I[20:10:28.410] Working directory: /home/adam/btrfs/btrfs-progs","I[20:10:28.410] argv[0]: clangd","I[20:10:28.410] argv[1]: -compile-commands-dir=/home/adam/compile_commands.d/btrfs-progs/","I[20:10:28.410] Starting LSP over stdin/stdout","I[20:10:28.410] <-- initialize(1)","I[20:10:28.410] --> reply:initialize(1) 0 ms","I[20:10:28.417] <-- initialized","I[20:10:28.417] unhandled notification initialized","I[20:10:28.420] <-- textDocument/didOpen",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["I[20:10:28.421] Enqueueing 95 commands for indexing",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["I[20:10:28.421] Updating file /home/adam/btrfs/btrfs-progs/disk-io.c with command ","[/home/adam/btrfs/btrfs-progs]","gcc -c -g -O1 -Wall -D_FORTIFY_SOURCE=2 -std=gnu90 -include config.h -DBTRFS_FLAT_INCLUDES -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC -I. -I./kernel-lib -I./libbtrfsutil -Wno-format-truncation -o disk-io.o disk-io.c -fsyntax-only -resource-dir=/usr/lib/clang/9.0.0",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-fi-usage.c to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/namespaceobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/ceval.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/pydebug.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/bytesobject.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/bytearrayobject.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/memoryobject.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/longintrepr.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/rbtree-utils.c to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-inspect.c to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/pyhash.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/genobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-subvolume.c to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-property.c to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/cellobject.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/utils.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/methodobject.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/dictobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/traceback.h to validate stored index: No such file or directory","E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/pystrtod.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/pytime.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/pyatomic.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/pymacconfig.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-rescue.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.571] Background-index: Couldn't read /usr/include/python3.7m/context.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/messages.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-quota.c to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/weakrefobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/pyerrors.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/eval.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/super-recover.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/setobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/fsfeatures.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/enumobject.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/iterobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/codecs.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-scrub.c to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-send.c to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/bltinmodule.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-inspect-dump-tree.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/sliceobject.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/listobject.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/typeslots.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/pymacro.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/funcobject.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/help.c to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-qgroup.c to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/pyctype.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/complexobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/structmember.h to validate stored index: No such file or directory","E[20:10:28.572] Background-index: Couldn't read /usr/include/python3.7m/dtoa.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pythonrun.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pyfpe.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/object.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pystrcmp.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/floatobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/fileobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/tupleobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/longobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/fileutils.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/abstract.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pylifecycle.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-inspect-tree-stats.c to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-inspect-dump-super.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pycapsule.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/patchlevel.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-replace.c to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/objimpl.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-restore.c to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/intrcheck.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-device.c to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/boolobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/sysmodule.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/modsupport.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/descrobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pyport.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-fi-du.c to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/warnings.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/chunk-recover.c to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/Python.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/string-table.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/osmodule.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pyarena.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pystate.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/task-utils.c to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/moduleobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/unicodeobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/compile.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pythread.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pymem.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/odictobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/classobject.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/structseq.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-filesystem.c to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/pyconfig.h to validate stored index: No such file or directory","E[20:10:28.573] Background-index: Couldn't read /usr/include/python3.7m/rangeobject.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["E[20:10:28.574] Background-index: Couldn't read /usr/include/python3.7m/pymath.h to validate stored index: No such file or directory","E[20:10:28.574] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-receive.c to validate stored index: No such file or directory","E[20:10:28.574] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/cmds-balance.c to validate stored index: No such file or directory","E[20:10:28.574] Background-index: Couldn't read /usr/include/python3.7m/import.h to validate stored index: No such file or directory","E[20:10:28.574] Background-index: Couldn't read /usr/include/python3.7m/code.h to validate stored index: No such file or directory","E[20:10:28.574] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/qgroup-verify.c to validate stored index: No such file or directory","E[20:10:28.574] Background-index: Couldn't read /home/adam/btrfs/btrfs-progs/qgroup-verify.h to validate stored index: No such file or directory",""]]
Sat 16 Nov 2019 08:10:28 PM CST:["<---",1,"clangd",{"response":{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"diagnostics":[],"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c"}}}]
Sat 16 Nov 2019 08:10:28 PM CST:["<---(stderr)",1,"clangd",["I[20:10:28.590] --> textDocument/publishDiagnostics",""]]
Sat 16 Nov 2019 08:10:30 PM CST:["s:on_text_document_did_change()",1]
Sat 16 Nov 2019 08:10:30 PM CST:["s:send_didchange_queue() will be triggered"]
Sat 16 Nov 2019 08:10:30 PM CST:["s:on_text_document_did_change()",1]
Sat 16 Nov 2019 08:10:30 PM CST:["s:on_text_document_did_change()",1]
Sat 16 Nov 2019 08:10:33 PM CST:[{"response":{"data":{"__data__":"vim-lsp","server_name":"clangd"},"message":"server already started"}}]
Sat 16 Nov 2019 08:10:33 PM CST:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"documentHighlightProvider":true,"hoverProvider":true,"workspaceSymbolProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"codeActionProvider":true,"textDocumentSync":2,"declarationProvider":true,"documentOnTypeFormattingProvider":{"moreTriggerCharacter":[],"firstTriggerCharacter":"\n"},"definitionProvider":true,"documentRangeFormattingProvider":true,"typeHierarchyProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"renameProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",">",":"]}}}},"server_name":"clangd"},"message":"lsp server already initialized"}}]
Sat 16 Nov 2019 08:10:33 PM CST:[{"response":{"data":{"__data__":"vim-lsp","server_name":"clangd"},"message":"configuration sent"}}]
Sat 16 Nov 2019 08:10:33 PM CST:[{"response":{"data":{"path":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","__data__":"vim-lsp","server_name":"clangd"},"message":"already opened"}}]
Sat 16 Nov 2019 08:10:33 PM CST:["s:update_file_content()",1]
Sat 16 Nov 2019 08:10:33 PM CST:["--->",1,"clangd",{"method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":1,"line":76},"start":{"character":1,"line":76}},"text":"list_ad\n\t","rangeLength":0}],"textDocument":{"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","version":2}}}]
Sat 16 Nov 2019 08:10:33 PM CST:[{"response":{"data":{"path":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","__data__":"vim-lsp","server_name":"clangd"},"message":"textDocument/didChange sent"}}]
Sat 16 Nov 2019 08:10:33 PM CST:["--->",1,"clangd",{"method":"textDocument/completion","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c"},"position":{"character":8,"line":76}}}]
Sat 16 Nov 2019 08:10:33 PM CST:["<---",1,"clangd",{"response":{"id":2,"jsonrpc":"2.0","result":{"isIncomplete":false,"items":[{"label":"•list_add_tail(struct list_head *xnew, struct list_head *head)","additionalTextEdits":[{"range":{"end":{"character":0,"line":29},"start":{"character":0,"line":29}},"newText":"#include \"list.h\"\n"}],"sortText":"4010e852list_add_tail","kind":3,"insertTextFormat":1,"documentation":"\n list_add_tail - add a new entry\n @new: new entry to be added\n @head: list head to add it before\n\n Insert a new entry before the specified head.\n This is useful for implementing queues.\n ","filterText":"list_add_tail","insertText":"list_add_tail","textEdit":{"range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"newText":"list_add_tail"},"detail":"void\n\"list.h\""},{"label":"•list_add(struct list_head *xnew, struct list_head *head)","additionalTextEdits":[{"range":{"end":{"character":0,"line":29},"start":{"character":0,"line":29}},"newText":"#include \"list.h\"\n"}],"sortText":"403ec9eflist_add","insertTextFormat":1,"insertText":"list_add","filterText":"list_add","kind":3,"textEdit":{"range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"newText":"list_add"},"detail":"void\n\"list.h\""},{"label":"•badblocks_list_add(badblocks_list bb, blk_t blk)","additionalTextEdits":[{"range":{"end":{"character":0,"line":18},"start":{"character":0,"line":18}},"newText":"#include <ext2fs/ext2fs.h>\n"}],"sortText":"40c532c4badblocks_list_add","insertTextFormat":1,"insertText":"badblocks_list_add","filterText":"badblocks_list_add","kind":3,"textEdit":{"range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"newText":"badblocks_list_add"},"detail":"errcode_t\n<ext2fs/ext2fs.h>"},{"label":"•ext2fs_badblocks_list_add(ext2_badblocks_list bb, blk_t blk)","additionalTextEdits":[{"range":{"end":{"character":0,"line":18},"start":{"character":0,"line":18}},"newText":"#include <ext2fs/ext2fs.h>\n"}],"sortText":"40cd51f4ext2fs_badblocks_list_add","insertTextFormat":1,"insertText":"ext2fs_badblocks_list_add","filterText":"ext2fs_badblocks_list_add","kind":3,"textEdit":{"range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"newText":"ext2fs_badblocks_list_add"},"detail":"errcode_t\n<ext2fs/ext2fs.h>"},{"label":"•ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk)","additionalTextEdits":[{"range":{"end":{"character":0,"line":18},"start":{"character":0,"line":18}},"newText":"#include <ext2fs/ext2fs.h>\n"}],"sortText":"40cd51f4ext2fs_u32_list_add","insertTextFormat":1,"insertText":"ext2fs_u32_list_add","filterText":"ext2fs_u32_list_add","kind":3,"textEdit":{"range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"newText":"ext2fs_u32_list_add"},"detail":"errcode_t\n<ext2fs/ext2fs.h>"},{"label":"•__list_add(struct list_head *xnew, struct list_head *prev, struct list_head *next)","additionalTextEdits":[{"range":{"end":{"character":0,"line":29},"start":{"character":0,"line":29}},"newText":"#include \"list.h\"\n"}],"sortText":"42030747__list_add","insertTextFormat":1,"insertText":"__list_add","filterText":"__list_add","kind":3,"textEdit":{"range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"newText":"__list_add"},"detail":"void\n\"list.h\""}]}},"request":{"id":2,"jsonrpc":"2.0","method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c"},"position":{"character":8,"line":76}}}}]
Sat 16 Nov 2019 08:10:33 PM CST:["<---(stderr)",1,"clangd",["I[20:10:33.606] <-- textDocument/didChange","I[20:10:33.607] <-- textDocument/completion(2)","I[20:10:33.611] Code complete: sema context Statement, query scopes [] (AnyScope=true), expected type <none>","I[20:10:33.611] Code complete: 0 results from Sema, 6 from Index, 0 matched, 0 from identifiers, 6 returned.","I[20:10:33.611] --> reply:textDocument/completion(2) 4 ms",""]]
Sat 16 Nov 2019 08:10:34 PM CST:["<---(stderr)",1,"clangd",["I[20:10:34.107] Updating file /home/adam/btrfs/btrfs-progs/disk-io.c with command ","[/home/adam/btrfs/btrfs-progs]","gcc -c -g -O1 -Wall -D_FORTIFY_SOURCE=2 -std=gnu90 -include config.h -DBTRFS_FLAT_INCLUDES -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC -I. -I./kernel-lib -I./libbtrfsutil -Wno-format-truncation -o disk-io.o disk-io.c -fsyntax-only -resource-dir=/usr/lib/clang/9.0.0",""]]
Sat 16 Nov 2019 08:10:34 PM CST:["<---(stderr)",1,"clangd",["I[20:10:34.141] --> textDocument/publishDiagnostics",""]]
Sat 16 Nov 2019 08:10:34 PM CST:["<---",1,"clangd",{"response":{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"diagnostics":[{"source":"clang","range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"code":"undeclared_var_use_suggest","message":"Use of undeclared identifier 'list_ad'; did you mean 'list_add'? (fix available)\n\n/home/adam/btrfs/btrfs-progs/kernel-lib/list.h:81:20:\nnote: 'list_add' declared here","severity":1},{"source":"clang","range":{"end":{"character":6,"line":77},"start":{"character":1,"line":77}},"code":"expected_semi_after_expr","message":"Expected ';' after expression (fix available)","severity":1},{"source":"clang","range":{"end":{"character":8,"line":76},"start":{"character":1,"line":76}},"code":"-Wunused-value","message":"Expression result unused","severity":2}],"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c"}}}]
Sat 16 Nov 2019 08:10:34 PM CST:["add signs",1]
Sat 16 Nov 2019 08:10:34 PM CST:["add signs",2]
Sat 16 Nov 2019 08:10:34 PM CST:["add signs",3]
Sat 16 Nov 2019 08:10:34 PM CST:["s:send_event_queue()"]
Sat 16 Nov 2019 08:10:34 PM CST:[{"response":{"data":{"__data__":"vim-lsp","server_name":"clangd"},"message":"server already started"}}]
Sat 16 Nov 2019 08:10:34 PM CST:[{"response":{"data":{"__data__":"vim-lsp","init_result":{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"documentHighlightProvider":true,"hoverProvider":true,"workspaceSymbolProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"codeActionProvider":true,"textDocumentSync":2,"declarationProvider":true,"documentOnTypeFormattingProvider":{"moreTriggerCharacter":[],"firstTriggerCharacter":"\n"},"definitionProvider":true,"documentRangeFormattingProvider":true,"typeHierarchyProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"renameProvider":true,"completionProvider":{"resolveProvider":false,"triggerCharacters":[".",">",":"]}}}},"server_name":"clangd"},"message":"lsp server already initialized"}}]
Sat 16 Nov 2019 08:10:34 PM CST:[{"response":{"data":{"__data__":"vim-lsp","server_name":"clangd"},"message":"configuration sent"}}]
Sat 16 Nov 2019 08:10:34 PM CST:[{"response":{"data":{"path":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","__data__":"vim-lsp","server_name":"clangd"},"message":"already opened"}}]
Sat 16 Nov 2019 08:10:34 PM CST:["s:update_file_content()",1]
Sat 16 Nov 2019 08:10:34 PM CST:["--->",1,"clangd",{"method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":8,"line":76},"start":{"character":8,"line":76}},"text":"d_tail","rangeLength":0}],"textDocument":{"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","version":3}}}]
Sat 16 Nov 2019 08:10:34 PM CST:[{"response":{"data":{"path":"file:///home/adam/btrfs/btrfs-progs/disk-io.c","__data__":"vim-lsp","server_name":"clangd"},"message":"textDocument/didChange sent"}}]
Sat 16 Nov 2019 08:10:34 PM CST:["<---(stderr)",1,"clangd",["I[20:10:34.837] <-- textDocument/didChange",""]]
Sat 16 Nov 2019 08:10:35 PM CST:["s:build_cmd","keepjumps keepalt b 1 | execute 'keepjumps normal! 77GzO77GzO77G01lv77G021l\"=l:merged_text_edit[''merged''][''newText''].''?''\rgph\"_x'"]
Sat 16 Nov 2019 08:10:35 PM CST:["s:build_cmd","keepjumps keepalt b 1 | execute 'keepjumps normal! 30G0\"=l:merged_text_edit[''merged''][''newText''].''?''\rgPh\"_x'"]
Sat 16 Nov 2019 08:10:35 PM CST:["<---(stderr)",1,"clangd",["I[20:10:35.337] Updating file /home/adam/btrfs/btrfs-progs/disk-io.c with command ","[/home/adam/btrfs/btrfs-progs]","gcc -c -g -O1 -Wall -D_FORTIFY_SOURCE=2 -std=gnu90 -include config.h -DBTRFS_FLAT_INCLUDES -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC -I. -I./kernel-lib -I./libbtrfsutil -Wno-format-truncation -o disk-io.o disk-io.c -fsyntax-only -resource-dir=/usr/lib/clang/9.0.0",""]]
Sat 16 Nov 2019 08:10:35 PM CST:["<---(stderr)",1,"clangd",["I[20:10:35.375] --> textDocument/publishDiagnostics",""]]
Sat 16 Nov 2019 08:10:35 PM CST:["<---",1,"clangd",{"response":{"method":"textDocument/publishDiagnostics","jsonrpc":"2.0","params":{"diagnostics":[{"source":"clang","range":{"end":{"character":6,"line":77},"start":{"character":1,"line":77}},"code":"expected_semi_after_expr","message":"Expected ';' after expression (fix available)","severity":1},{"source":"clang","range":{"end":{"character":14,"line":76},"start":{"character":1,"line":76}},"code":"-Wunused-value","message":"Expression result unused","severity":2}],"uri":"file:///home/adam/btrfs/btrfs-progs/disk-io.c"}}}]
Sat 16 Nov 2019 08:10:35 PM CST:["add signs",1]
Sat 16 Nov 2019 08:10:35 PM CST:["add signs",2]
Sat 16 Nov 2019 08:10:36 PM CST:["s:on_text_document_did_change()",1]
Sat 16 Nov 2019 08:10:36 PM CST:["s:send_didchange_queue() will be triggered"]
Sat 16 Nov 2019 08:10:36 PM CST:["s:on_text_document_did_close()",1]
Sat 16 Nov 2019 08:10:36 PM CST:["s:on_text_document_did_close()",1]
Sat 16 Nov 2019 08:10:40 PM CST:["lsp#register_server","server registered","clangd"]
Sat 16 Nov 2019 08:10:40 PM CST:["vim-lsp signs enabled"]
Sat 16 Nov 2019 08:10:40 PM CST:["vim-lsp highlighting enabled (textprop)"]
Sat 16 Nov 2019 08:10:40 PM CST:["s:on_text_document_did_open()",1,"","/home/adam/btrfs/btrfs-progs","file:///tmp/lsp.log"]
Sat 16 Nov 2019 08:11:10 PM CST:["s:on_text_document_did_close()",1]
Sat 16 Nov 2019 08:11:20 PM CST:["lsp#register_server","server registered","clangd"]
Sat 16 Nov 2019 08:11:20 PM CST:["vim-lsp signs enabled"]
Sat 16 Nov 2019 08:11:20 PM CST:["vim-lsp highlighting enabled (textprop)"]
Sat 16 Nov 2019 08:11:20 PM CST:["s:on_text_document_did_open()",1,"","/home/adam/btrfs/btrfs-progs","file:///tmp/lsp.log"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment