Author: kpvdr
Date: 2008-12-17 13:21:34 -0500 (Wed, 17 Dec 2008)
New Revision: 3017
Modified:
store/trunk/cpp/lib/jrnl/fcntl.cpp
store/trunk/cpp/lib/jrnl/fcntl.hpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jcntl.hpp
store/trunk/cpp/lib/jrnl/rmgr.cpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
Log:
Fix for intermittent JERR_FCNTL_RDOFFSOVFL and JERR_RMGR_UNKNOWNMAGIC errors, especially
during _st_read.increasing_interval_delayed_read test, but also during recovery
(BZ466533).
Modified: store/trunk/cpp/lib/jrnl/fcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/fcntl.cpp 2008-12-17 18:03:47 UTC (rev 3016)
+++ store/trunk/cpp/lib/jrnl/fcntl.cpp 2008-12-17 18:21:34 UTC (rev 3017)
@@ -57,7 +57,8 @@
_rd_cmpl_cnt_dblks(0),
_wr_subm_cnt_dblks(0),
_wr_cmpl_cnt_dblks(0),
- _aio_cnt(0)
+ _aio_cnt(0),
+ _fhdr_wr_aio_outstanding(false)
{
initialize(fbasename, fid, lid, jfsize_sblks, ro);
open_wr_fh();
Modified: store/trunk/cpp/lib/jrnl/fcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/fcntl.hpp 2008-12-17 18:03:47 UTC (rev 3016)
+++ store/trunk/cpp/lib/jrnl/fcntl.hpp 2008-12-17 18:21:34 UTC (rev 3017)
@@ -68,6 +68,7 @@
u_int32_t _wr_subm_cnt_dblks; ///< Write file count (data blocks) for
submitted AIO
u_int32_t _wr_cmpl_cnt_dblks; ///< Write file count (data blocks) for
completed AIO
u_int16_t _aio_cnt; ///< Outstanding AIO operations on this file
+ bool _fhdr_wr_aio_outstanding; ///< Outstanding file header write on this
file
public:
// Constructors with implicit initialize() and open()
@@ -114,6 +115,9 @@
inline u_int16_t incr_aio_cnt() { return ++_aio_cnt; }
u_int16_t decr_aio_cnt();
+ inline bool wr_fhdr_aio_outstanding() { return _fhdr_wr_aio_outstanding; }
+ inline void set_wr_fhdr_aio_outstanding(const bool wfao) {
_fhdr_wr_aio_outstanding = wfao; }
+
// Derived helper functions
inline bool rd_void() const { return _wr_cmpl_cnt_dblks == 0; }
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2008-12-17 18:03:47 UTC (rev 3016)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2008-12-17 18:21:34 UTC (rev 3017)
@@ -430,6 +430,24 @@
_rmgr.invalidate();
}
+#define AIO_CMPL_SLEEP 200 // 0.2 ms
+#define MAX_AIO_CMPL_SLEEPS 50000 // Total: 10 sec
+
+void
+jcntl::fhdr_wr_sync(const u_int16_t lid)
+{
+ long cnt = 0;
+ fcntl* fcntlp = _lfmgr.get_fcntlp(lid);
+ get_wr_events();
+ while (fcntlp->wr_fhdr_aio_outstanding())
+ {
+ if (++cnt > AIO_CMPL_SLEEP)
+ throw jexception(jerrno::JERR_JCNTL_AIOCMPLWAIT, "jcntl",
"fhdr_wr_sync");
+ ::usleep(MAX_AIO_CMPL_SLEEPS);
+ get_wr_events();
+ }
+}
+
fcntl*
jcntl::new_fcntl(jcntl* const jcp, const u_int16_t lid, const u_int16_t fid, const
rcvdat* const rdp)
{
@@ -476,9 +494,6 @@
ji.write();
}
-#define AIO_CMPL_SLEEP 200 // 0.2 ms
-#define MAX_AIO_CMPL_SLEEPS 50000 // Total: 10 sec
-
void
jcntl::aio_cmpl_wait()
{
Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp 2008-12-17 18:03:47 UTC (rev 3016)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp 2008-12-17 18:21:34 UTC (rev 3017)
@@ -645,6 +645,7 @@
// FIXME these are _rmgr to _wmgr interactions, remove when _rmgr contains ref to
_wmgr:
void chk_wr_frot();
inline u_int32_t unflushed_dblks() { return _wmgr.unflushed_dblks(); }
+ void fhdr_wr_sync(const u_int16_t lid);
// Management instrumentation callbacks
inline virtual void instr_incr_outstanding_aio_cnt() {}
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-12-17 18:03:47 UTC (rev 3016)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-12-17 18:21:34 UTC (rev 3017)
@@ -144,8 +144,7 @@
aio_cycle();
return RHM_IORES_PAGE_AIOWAIT;
}
- void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] +
- (_pg_offset_dblks * JRNL_DBLK_SIZE));
+ void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] + (_pg_offset_dblks *
JRNL_DBLK_SIZE));
std::memcpy(&_hdr, rptr, sizeof(rec_hdr));
switch (_hdr._magic)
{
@@ -667,6 +666,7 @@
void
rmgr::init_file_header_read()
{
+ _jc->fhdr_wr_sync(_rrfc.fid()); // wait if the file header write is outstanding
int rfh = _rrfc.fh();
aio::prep_pread_2(_fhdr_aio_cb_ptr, rfh, _fhdr_buffer, _sblksize, 0);
if (aio::submit(_ioctx, 1, &_fhdr_aio_cb_ptr) < 0)
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2008-12-17 18:03:47 UTC (rev 3016)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2008-12-17 18:21:34 UTC (rev 3017)
@@ -876,6 +876,7 @@
fcntl* fcntlp = _jc->get_fcntlp(fid);
fcntlp->add_wr_cmpl_cnt_dblks(JRNL_SBLK_SIZE);
fcntlp->decr_aio_cnt();
+ fcntlp->set_wr_fhdr_aio_outstanding(false);
}
}
@@ -1062,6 +1063,7 @@
_aio_evt_rem++;
_wrfc.add_subm_cnt_dblks(JRNL_SBLK_SIZE);
_wrfc.incr_aio_cnt();
+ _wrfc.file_controller()->set_wr_fhdr_aio_outstanding(true);
}
void