* [9fans] bufreset deletes b->nbl-1 blocks? @ 2016-08-12 12:30 Costin Chirvasuta 2016-08-12 15:20 ` James A. Robinson 0 siblings, 1 reply; 7+ messages in thread From: Costin Chirvasuta @ 2016-08-12 12:30 UTC (permalink / raw) To: 9fans I'm reading the sam source (very educational) and I've stumbled across a piece I don't understand, in buff.c:^bufreset: for(i=b->nbl-1; --i>=0; ) delblock(b, i); Doesn't this delete b-nbl-1 blocks? Also delblock would always call memmove, moving 1 block at the end, if I read it correctly. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] bufreset deletes b->nbl-1 blocks? 2016-08-12 12:30 [9fans] bufreset deletes b->nbl-1 blocks? Costin Chirvasuta @ 2016-08-12 15:20 ` James A. Robinson 2016-08-12 15:29 ` Costin Chirvasuta 0 siblings, 1 reply; 7+ messages in thread From: James A. Robinson @ 2016-08-12 15:20 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 211 bytes --] But delblock only calls memmove if i is less then b->nbl, which was just decremented, correct? So isn't the memmove just to cover the case where you are deleting a block that isn't at the very end? Jim [-- Attachment #2: Type: text/html, Size: 331 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] bufreset deletes b->nbl-1 blocks? 2016-08-12 15:20 ` James A. Robinson @ 2016-08-12 15:29 ` Costin Chirvasuta 2016-08-12 15:48 ` James A. Robinson 0 siblings, 1 reply; 7+ messages in thread From: Costin Chirvasuta @ 2016-08-12 15:29 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs > So isn't the memmove just to cover the case where you are > deleting a block that isn't at the very end? Yes, but from what I understand i is always lower. Say b->nbl starts at 10. i=b->nbl-1 so i=9. --i so i=8. Inside delblock b->nbl-- so b->nbl is 9. i<nbl is true so the memmove happens. Also delblock(b, 0) never seems to happen. On Fri, Aug 12, 2016 at 6:20 PM, James A. Robinson <jim.robinson@gmail.com> wrote: > But delblock only calls memmove if i is less then b->nbl, which was > just decremented, correct? > > So isn't the memmove just to cover the case where you are > deleting a block that isn't at the very end? > > Jim > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] bufreset deletes b->nbl-1 blocks? 2016-08-12 15:29 ` Costin Chirvasuta @ 2016-08-12 15:48 ` James A. Robinson 2016-08-12 16:10 ` Costin Chirvasuta 0 siblings, 1 reply; 7+ messages in thread From: James A. Robinson @ 2016-08-12 15:48 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 752 bytes --] On Fri, Aug 12, 2016 at 8:32 AM Costin Chirvasuta <costinc@gmail.com> wrote: > > So isn't the memmove just to cover the case where you are > > deleting a block that isn't at the very end? > > Yes, but from what I understand i is always lower. > > Say b->nbl starts at 10. i=b->nbl-1 so i=9. --i so i=8. > Inside delblock b->nbl-- so b->nbl is 9. i<nbl is true so the memmove > happens. > > Also delblock(b, 0) never seems to happen. > My apologies, I wasn't paying enough attention. Yes, I think you're correct that if b->nbl is 10 it would start off with deblock(b, 8). Why wouldn't delblock(b, 0) be called? Wouldn't the sequence end up being 8,7,6,5,4,3,2,1,0, since only when it hits i=-1 would it evaluate to false? Jim [-- Attachment #2: Type: text/html, Size: 1129 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] bufreset deletes b->nbl-1 blocks? 2016-08-12 15:48 ` James A. Robinson @ 2016-08-12 16:10 ` Costin Chirvasuta 2016-08-12 16:16 ` James A. Robinson 0 siblings, 1 reply; 7+ messages in thread From: Costin Chirvasuta @ 2016-08-12 16:10 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs Sorry, you're right, delblock(b, 0) is called. delblock(b, 9) isn't called. It's called for the sequence 8..0, as you stated. So is this correct? Doesn't this mean one block will never get released back to the temporary disc? On Fri, Aug 12, 2016 at 6:48 PM, James A. Robinson <jim.robinson@gmail.com> wrote: > On Fri, Aug 12, 2016 at 8:32 AM Costin Chirvasuta <costinc@gmail.com> wrote: >> >> > So isn't the memmove just to cover the case where you are >> > deleting a block that isn't at the very end? >> >> Yes, but from what I understand i is always lower. >> >> Say b->nbl starts at 10. i=b->nbl-1 so i=9. --i so i=8. >> Inside delblock b->nbl-- so b->nbl is 9. i<nbl is true so the memmove >> happens. >> >> Also delblock(b, 0) never seems to happen. > > > My apologies, I wasn't paying enough attention. Yes, I think you're correct > that if b->nbl is 10 it would start off with deblock(b, 8). > > Why wouldn't delblock(b, 0) be called? Wouldn't the sequence end up being > 8,7,6,5,4,3,2,1,0, since only when it hits i=-1 would it evaluate to false? > > Jim > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] bufreset deletes b->nbl-1 blocks? 2016-08-12 16:10 ` Costin Chirvasuta @ 2016-08-12 16:16 ` James A. Robinson 2016-08-12 16:25 ` Costin Chirvasuta 0 siblings, 1 reply; 7+ messages in thread From: James A. Robinson @ 2016-08-12 16:16 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 143 bytes --] Have you checked whether or not that final block is special in some way? For example only mapped to memory and not to disk blocks? Jim [-- Attachment #2: Type: text/html, Size: 259 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [9fans] bufreset deletes b->nbl-1 blocks? 2016-08-12 16:16 ` James A. Robinson @ 2016-08-12 16:25 ` Costin Chirvasuta 0 siblings, 0 replies; 7+ messages in thread From: Costin Chirvasuta @ 2016-08-12 16:25 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs I believe bufreset can be called at any time and b->cbi (the current cached block) can point to anything. Either way, that block is never returned to the Disc's free list so that file address won't be reused from that point on. On Fri, Aug 12, 2016 at 7:16 PM, James A. Robinson <jimr@highwire.org> wrote: > Have you checked whether or not that final block is > special in some way? For example only mapped to > memory and not to disk blocks? > > Jim > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-08-12 16:25 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-08-12 12:30 [9fans] bufreset deletes b->nbl-1 blocks? Costin Chirvasuta 2016-08-12 15:20 ` James A. Robinson 2016-08-12 15:29 ` Costin Chirvasuta 2016-08-12 15:48 ` James A. Robinson 2016-08-12 16:10 ` Costin Chirvasuta 2016-08-12 16:16 ` James A. Robinson 2016-08-12 16:25 ` Costin Chirvasuta
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).