{"action":"created","comment":{"url":"https://api.github.com/repos/travisg/lk/pulls/comments/43960430","id":43960430,"diff_hunk":"@@ -75,22 +75,34 @@ static ssize_t bio_default_read(struct bdev *dev, void *_buf, off_t offset, size\n     }\n \n     LTRACEF(\"buf %p, block %u, len %zd\\n\", buf, block, len);\n+\n+    // If the device requires alignment AND our buffer is not alread aligned.\n+    bool requires_alignment =\n+        (dev->flags & BIO_FLAG_CACHE_ALIGNED_READS) &&\n+        (IS_ALIGNED((size_t)buf, CACHE_LINE) == false);\n     /* handle middle blocks */\n-    if (len >= dev->block_size) {\n-        /* do the middle reads */\n-        size_t block_count = len / dev->block_size;\n-        err = bio_read_block(dev, buf, block, block_count);\n+    if (requires_alignment) {\n+        while (len >= dev->block_size) {\n+            /* do the middle reads */\n+            err = bio_read_block(dev, temp, block, 1);\n+            memcpy(buf, temp, dev->block_size);\n+            if (err < 0)","path":"lib/bio/bio.c","position":19,"original_position":19,"commit_id":"68c158d7970601d0e072210ee88a00d801f357b4","original_commit_id":"68c158d7970601d0e072210ee88a00d801f357b4","user":{"login":"gkalsi","id":1513257,"avatar_url":"https://avatars.githubusercontent.com/u/1513257?v=3","gravatar_id":"","url":"https://api.github.com/users/gkalsi","html_url":"https://github.com/gkalsi","followers_url":"https://api.github.com/users/gkalsi/followers","following_url":"https://api.github.com/users/gkalsi/following{/other_user}","gists_url":"https://api.github.com/users/gkalsi/gists{/gist_id}","starred_url":"https://api.github.com/users/gkalsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkalsi/subscriptions","organizations_url":"https://api.github.com/users/gkalsi/orgs","repos_url":"https://api.github.com/users/gkalsi/repos","events_url":"https://api.github.com/users/gkalsi/events{/privacy}","received_events_url":"https://api.github.com/users/gkalsi/received_events","type":"User","site_admin":false},"body":"good call, we should bail if no bytes are read, will fix.","created_at":"2015-11-05T00:08:38Z","updated_at":"2015-11-05T00:08:38Z","html_url":"https://github.com/travisg/lk/pull/67#discussion_r43960430","pull_request_url":"https://api.github.com/repos/travisg/lk/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/travisg/lk/pulls/comments/43960430"},"html":{"href":"https://github.com/travisg/lk/pull/67#discussion_r43960430"},"pull_request":{"href":"https://api.github.com/repos/travisg/lk/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/travisg/lk/pulls/67","id":49627528,"html_url":"https://github.com/travisg/lk/pull/67","diff_url":"https://github.com/travisg/lk/pull/67.diff","patch_url":"https://github.com/travisg/lk/pull/67.patch","issue_url":"https://api.github.com/repos/travisg/lk/issues/67","number":67,"state":"open","locked":false,"title":"Block IO Aligned Buffers","user":{"login":"gkalsi","id":1513257,"avatar_url":"https://avatars.githubusercontent.com/u/1513257?v=3","gravatar_id":"","url":"https://api.github.com/users/gkalsi","html_url":"https://github.com/gkalsi","followers_url":"https://api.github.com/users/gkalsi/followers","following_url":"https://api.github.com/users/gkalsi/following{/other_user}","gists_url":"https://api.github.com/users/gkalsi/gists{/gist_id}","starred_url":"https://api.github.com/users/gkalsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkalsi/subscriptions","organizations_url":"https://api.github.com/users/gkalsi/orgs","repos_url":"https://api.github.com/users/gkalsi/repos","events_url":"https://api.github.com/users/gkalsi/events{/privacy}","received_events_url":"https://api.github.com/users/gkalsi/received_events","type":"User","site_admin":false},"body":"+ Add a flags field inside `bdev_t`\r\n+ Allow devices to mark themselves as requiring cache aligned buffers\r\n+ [STM32F7 Spiflash] require cache aligned buffers\r\n+ [STM32F7 Spiflash] use default implementation for `bio_read`\r\n+ Don't allocate on the stack for `bio dump` since this blows the stack","created_at":"2015-11-03T23:22:31Z","updated_at":"2015-11-05T00:08:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ce28bf93e9471c602d138e084c6458cbff94f4b6","assignee":{"login":"travisg","id":97708,"avatar_url":"https://avatars.githubusercontent.com/u/97708?v=3","gravatar_id":"","url":"https://api.github.com/users/travisg","html_url":"https://github.com/travisg","followers_url":"https://api.github.com/users/travisg/followers","following_url":"https://api.github.com/users/travisg/following{/other_user}","gists_url":"https://api.github.com/users/travisg/gists{/gist_id}","starred_url":"https://api.github.com/users/travisg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travisg/subscriptions","organizations_url":"https://api.github.com/users/travisg/orgs","repos_url":"https://api.github.com/users/travisg/repos","events_url":"https://api.github.com/users/travisg/events{/privacy}","received_events_url":"https://api.github.com/users/travisg/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/travisg/lk/pulls/67/commits","review_comments_url":"https://api.github.com/repos/travisg/lk/pulls/67/comments","review_comment_url":"https://api.github.com/repos/travisg/lk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/travisg/lk/issues/67/comments","statuses_url":"https://api.github.com/repos/travisg/lk/statuses/68c158d7970601d0e072210ee88a00d801f357b4","head":{"label":"travisg:pr_qspi_aligned_buffers","ref":"pr_qspi_aligned_buffers","sha":"68c158d7970601d0e072210ee88a00d801f357b4","user":{"login":"travisg","id":97708,"avatar_url":"https://avatars.githubusercontent.com/u/97708?v=3","gravatar_id":"","url":"https://api.github.com/users/travisg","html_url":"https://github.com/travisg","followers_url":"https://api.github.com/users/travisg/followers","following_url":"https://api.github.com/users/travisg/following{/other_user}","gists_url":"https://api.github.com/users/travisg/gists{/gist_id}","starred_url":"https://api.github.com/users/travisg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travisg/subscriptions","organizations_url":"https://api.github.com/users/travisg/orgs","repos_url":"https://api.github.com/users/travisg/repos","events_url":"https://api.github.com/users/travisg/events{/privacy}","received_events_url":"https://api.github.com/users/travisg/received_events","type":"User","site_admin":false},"repo":{"id":3058456,"name":"lk","full_name":"travisg/lk","owner":{"login":"travisg","id":97708,"avatar_url":"https://avatars.githubusercontent.com/u/97708?v=3","gravatar_id":"","url":"https://api.github.com/users/travisg","html_url":"https://github.com/travisg","followers_url":"https://api.github.com/users/travisg/followers","following_url":"https://api.github.com/users/travisg/following{/other_user}","gists_url":"https://api.github.com/users/travisg/gists{/gist_id}","starred_url":"https://api.github.com/users/travisg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travisg/subscriptions","organizations_url":"https://api.github.com/users/travisg/orgs","repos_url":"https://api.github.com/users/travisg/repos","events_url":"https://api.github.com/users/travisg/events{/privacy}","received_events_url":"https://api.github.com/users/travisg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/travisg/lk","description":"LK embedded kernel","fork":false,"url":"https://api.github.com/repos/travisg/lk","forks_url":"https://api.github.com/repos/travisg/lk/forks","keys_url":"https://api.github.com/repos/travisg/lk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/travisg/lk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/travisg/lk/teams","hooks_url":"https://api.github.com/repos/travisg/lk/hooks","issue_events_url":"https://api.github.com/repos/travisg/lk/issues/events{/number}","events_url":"https://api.github.com/repos/travisg/lk/events","assignees_url":"https://api.github.com/repos/travisg/lk/assignees{/user}","branches_url":"https://api.github.com/repos/travisg/lk/branches{/branch}","tags_url":"https://api.github.com/repos/travisg/lk/tags","blobs_url":"https://api.github.com/repos/travisg/lk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/travisg/lk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/travisg/lk/git/refs{/sha}","trees_url":"https://api.github.com/repos/travisg/lk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/travisg/lk/statuses/{sha}","languages_url":"https://api.github.com/repos/travisg/lk/languages","stargazers_url":"https://api.github.com/repos/travisg/lk/stargazers","contributors_url":"https://api.github.com/repos/travisg/lk/contributors","subscribers_url":"https://api.github.com/repos/travisg/lk/subscribers","subscription_url":"https://api.github.com/repos/travisg/lk/subscription","commits_url":"https://api.github.com/repos/travisg/lk/commits{/sha}","git_commits_url":"https://api.github.com/repos/travisg/lk/git/commits{/sha}","comments_url":"https://api.github.com/repos/travisg/lk/comments{/number}","issue_comment_url":"https://api.github.com/repos/travisg/lk/issues/comments{/number}","contents_url":"https://api.github.com/repos/travisg/lk/contents/{+path}","compare_url":"https://api.github.com/repos/travisg/lk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/travisg/lk/merges","archive_url":"https://api.github.com/repos/travisg/lk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/travisg/lk/downloads","issues_url":"https://api.github.com/repos/travisg/lk/issues{/number}","pulls_url":"https://api.github.com/repos/travisg/lk/pulls{/number}","milestones_url":"https://api.github.com/repos/travisg/lk/milestones{/number}","notifications_url":"https://api.github.com/repos/travisg/lk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/travisg/lk/labels{/name}","releases_url":"https://api.github.com/repos/travisg/lk/releases{/id}","created_at":"2011-12-27T19:19:36Z","updated_at":"2015-11-03T18:54:04Z","pushed_at":"2015-11-04T23:48:51Z","git_url":"git://github.com/travisg/lk.git","ssh_url":"git@github.com:travisg/lk.git","clone_url":"https://github.com/travisg/lk.git","svn_url":"https://github.com/travisg/lk","homepage":"","size":18236,"stargazers_count":98,"watchers_count":98,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":66,"mirror_url":null,"open_issues_count":12,"forks":66,"open_issues":12,"watchers":98,"default_branch":"master"}},"base":{"label":"travisg:master","ref":"master","sha":"a79328fe976e116f97b3b7dc0908ed6fe93b6d18","user":{"login":"travisg","id":97708,"avatar_url":"https://avatars.githubusercontent.com/u/97708?v=3","gravatar_id":"","url":"https://api.github.com/users/travisg","html_url":"https://github.com/travisg","followers_url":"https://api.github.com/users/travisg/followers","following_url":"https://api.github.com/users/travisg/following{/other_user}","gists_url":"https://api.github.com/users/travisg/gists{/gist_id}","starred_url":"https://api.github.com/users/travisg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travisg/subscriptions","organizations_url":"https://api.github.com/users/travisg/orgs","repos_url":"https://api.github.com/users/travisg/repos","events_url":"https://api.github.com/users/travisg/events{/privacy}","received_events_url":"https://api.github.com/users/travisg/received_events","type":"User","site_admin":false},"repo":{"id":3058456,"name":"lk","full_name":"travisg/lk","owner":{"login":"travisg","id":97708,"avatar_url":"https://avatars.githubusercontent.com/u/97708?v=3","gravatar_id":"","url":"https://api.github.com/users/travisg","html_url":"https://github.com/travisg","followers_url":"https://api.github.com/users/travisg/followers","following_url":"https://api.github.com/users/travisg/following{/other_user}","gists_url":"https://api.github.com/users/travisg/gists{/gist_id}","starred_url":"https://api.github.com/users/travisg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travisg/subscriptions","organizations_url":"https://api.github.com/users/travisg/orgs","repos_url":"https://api.github.com/users/travisg/repos","events_url":"https://api.github.com/users/travisg/events{/privacy}","received_events_url":"https://api.github.com/users/travisg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/travisg/lk","description":"LK embedded kernel","fork":false,"url":"https://api.github.com/repos/travisg/lk","forks_url":"https://api.github.com/repos/travisg/lk/forks","keys_url":"https://api.github.com/repos/travisg/lk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/travisg/lk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/travisg/lk/teams","hooks_url":"https://api.github.com/repos/travisg/lk/hooks","issue_events_url":"https://api.github.com/repos/travisg/lk/issues/events{/number}","events_url":"https://api.github.com/repos/travisg/lk/events","assignees_url":"https://api.github.com/repos/travisg/lk/assignees{/user}","branches_url":"https://api.github.com/repos/travisg/lk/branches{/branch}","tags_url":"https://api.github.com/repos/travisg/lk/tags","blobs_url":"https://api.github.com/repos/travisg/lk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/travisg/lk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/travisg/lk/git/refs{/sha}","trees_url":"https://api.github.com/repos/travisg/lk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/travisg/lk/statuses/{sha}","languages_url":"https://api.github.com/repos/travisg/lk/languages","stargazers_url":"https://api.github.com/repos/travisg/lk/stargazers","contributors_url":"https://api.github.com/repos/travisg/lk/contributors","subscribers_url":"https://api.github.com/repos/travisg/lk/subscribers","subscription_url":"https://api.github.com/repos/travisg/lk/subscription","commits_url":"https://api.github.com/repos/travisg/lk/commits{/sha}","git_commits_url":"https://api.github.com/repos/travisg/lk/git/commits{/sha}","comments_url":"https://api.github.com/repos/travisg/lk/comments{/number}","issue_comment_url":"https://api.github.com/repos/travisg/lk/issues/comments{/number}","contents_url":"https://api.github.com/repos/travisg/lk/contents/{+path}","compare_url":"https://api.github.com/repos/travisg/lk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/travisg/lk/merges","archive_url":"https://api.github.com/repos/travisg/lk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/travisg/lk/downloads","issues_url":"https://api.github.com/repos/travisg/lk/issues{/number}","pulls_url":"https://api.github.com/repos/travisg/lk/pulls{/number}","milestones_url":"https://api.github.com/repos/travisg/lk/milestones{/number}","notifications_url":"https://api.github.com/repos/travisg/lk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/travisg/lk/labels{/name}","releases_url":"https://api.github.com/repos/travisg/lk/releases{/id}","created_at":"2011-12-27T19:19:36Z","updated_at":"2015-11-03T18:54:04Z","pushed_at":"2015-11-04T23:48:51Z","git_url":"git://github.com/travisg/lk.git","ssh_url":"git@github.com:travisg/lk.git","clone_url":"https://github.com/travisg/lk.git","svn_url":"https://github.com/travisg/lk","homepage":"","size":18236,"stargazers_count":98,"watchers_count":98,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":66,"mirror_url":null,"open_issues_count":12,"forks":66,"open_issues":12,"watchers":98,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/travisg/lk/pulls/67"},"html":{"href":"https://github.com/travisg/lk/pull/67"},"issue":{"href":"https://api.github.com/repos/travisg/lk/issues/67"},"comments":{"href":"https://api.github.com/repos/travisg/lk/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/travisg/lk/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/travisg/lk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/travisg/lk/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/travisg/lk/statuses/68c158d7970601d0e072210ee88a00d801f357b4"}}}}