return true;
}
-/*
- * mdwriteback() -- Tell the kernel to write pages back to storage.
- *
- * This accepts a range of blocks because flushing several pages at once is
- * considerably more efficient than doing so individually.
- */
-void
-mdwriteback(SMgrRelation reln, ForkNumber forknum,
- BlockNumber blocknum, BlockNumber nblocks)
-{
- Assert((io_direct_flags & IO_DIRECT_DATA) == 0);
-
- /*
- * Issue flush requests in as few requests as possible; have to split at
- * segment boundaries though, since those are actually separate files.
- */
- while (nblocks > 0)
- {
- BlockNumber nflush = nblocks;
- off_t seekpos;
- MdfdVec *v;
- int segnum_start,
- segnum_end;
-
- v = _mdfd_getseg(reln, forknum, blocknum, true /* not used */ ,
- EXTENSION_DONT_OPEN);
-
- /*
- * We might be flushing buffers of already removed relations, that's
- * ok, just ignore that case. If the segment file wasn't open already
- * (ie from a recent mdwrite()), then we don't want to re-open it, to
- * avoid a race with PROCSIGNAL_BARRIER_SMGRRELEASE that might leave
- * us with a descriptor to a file that is about to be unlinked.
- */
- if (!v)
- return;
-
- /* compute offset inside the current segment */
- segnum_start = blocknum / RELSEG_SIZE;
-
- /* compute number of desired writes within the current segment */
- segnum_end = (blocknum + nblocks - 1) / RELSEG_SIZE;
- if (segnum_start != segnum_end)
- nflush = RELSEG_SIZE - (blocknum % ((BlockNumber) RELSEG_SIZE));
-
- Assert(nflush >= 1);
- Assert(nflush <= nblocks);
-
- seekpos = (off_t) BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE));
-
- FileWriteback(v->mdfd_vfd, seekpos, (off_t) BLCKSZ * nflush, WAIT_EVENT_DATA_FILE_FLUSH);
-
- nblocks -= nflush;
- blocknum += nflush;
- }
-}
-
/*
* mdread() -- Read the specified block from a relation.
*/
register_dirty_segment(reln, forknum, v);
}
+/*
+ * mdwriteback() -- Tell the kernel to write pages back to storage.
+ *
+ * This accepts a range of blocks because flushing several pages at once is
+ * considerably more efficient than doing so individually.
+ */
+void
+mdwriteback(SMgrRelation reln, ForkNumber forknum,
+ BlockNumber blocknum, BlockNumber nblocks)
+{
+ Assert((io_direct_flags & IO_DIRECT_DATA) == 0);
+
+ /*
+ * Issue flush requests in as few requests as possible; have to split at
+ * segment boundaries though, since those are actually separate files.
+ */
+ while (nblocks > 0)
+ {
+ BlockNumber nflush = nblocks;
+ off_t seekpos;
+ MdfdVec *v;
+ int segnum_start,
+ segnum_end;
+
+ v = _mdfd_getseg(reln, forknum, blocknum, true /* not used */ ,
+ EXTENSION_DONT_OPEN);
+
+ /*
+ * We might be flushing buffers of already removed relations, that's
+ * ok, just ignore that case. If the segment file wasn't open already
+ * (ie from a recent mdwrite()), then we don't want to re-open it, to
+ * avoid a race with PROCSIGNAL_BARRIER_SMGRRELEASE that might leave
+ * us with a descriptor to a file that is about to be unlinked.
+ */
+ if (!v)
+ return;
+
+ /* compute offset inside the current segment */
+ segnum_start = blocknum / RELSEG_SIZE;
+
+ /* compute number of desired writes within the current segment */
+ segnum_end = (blocknum + nblocks - 1) / RELSEG_SIZE;
+ if (segnum_start != segnum_end)
+ nflush = RELSEG_SIZE - (blocknum % ((BlockNumber) RELSEG_SIZE));
+
+ Assert(nflush >= 1);
+ Assert(nflush <= nblocks);
+
+ seekpos = (off_t) BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE));
+
+ FileWriteback(v->mdfd_vfd, seekpos, (off_t) BLCKSZ * nflush, WAIT_EVENT_DATA_FILE_FLUSH);
+
+ nblocks -= nflush;
+ blocknum += nflush;
+ }
+}
+
/*
* mdnblocks() -- Get the number of blocks stored in a relation.
*