-
- memset (fileb, 0xeb, getpagesize ());
- rc = obdio_pread (conn, b->ob_oid, (void *)fileb, getpagesize (), 0);
- if (rc != 0) {
- fprintf (stderr, "obdio_barrier "LPX64": Error on initial read: %s\n",
- b->ob_oid, strerror (errno));
- goto out_2;
- }
-
- if (fileb->ob_id != b->ob_id ||
- fileb->ob_oid != b->ob_oid ||
- fileb->ob_npeers != b->ob_npeers ||
- fileb->ob_count >= b->ob_npeers ||
- fileb->ob_ordinal != b->ob_ordinal) {
- fprintf (stderr, "obdio_barrier "LPX64": corrupt on initial read\n", b->ob_id);
- fprintf (stderr, " got ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n",
- fileb->ob_id, fileb->ob_oid, fileb->ob_npeers,
- fileb->ob_ordinal, fileb->ob_count);
- fprintf (stderr, " expected ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n",
- b->ob_id, b->ob_oid, b->ob_npeers,
- b->ob_ordinal, b->ob_count);
- rc = -1;
- goto out_2;
- }
-
- fileb->ob_count++;
- if (fileb->ob_count == fileb->ob_npeers) { /* I'm the last joiner */
- fileb->ob_count = 0; /* join count for next barrier */
- fileb->ob_ordinal++; /* signal all joined */
- }
-
- rc = obdio_pwrite (conn, b->ob_oid, (void *)fileb, getpagesize (), 0);
- if (rc != 0) {
- fprintf (stderr, "obdio_barrier "LPX64": Error on initial write: %s\n",
- b->ob_oid, strerror (errno));
- goto out_2;
- }
-
- mode = "PW";
- b->ob_ordinal++; /* now I wait... */
- while (fileb->ob_ordinal != b->ob_ordinal) {
-
- rc = obdio_cancel (conn, &lh);
- if (rc != 0) {
- fprintf (stderr, "obdio_barrier "LPX64": Error on %s cancel: %s\n",
- b->ob_oid, mode, strerror (errno));
- goto out_1;
- }
-
- mode = "PR";
- rc = obdio_enqueue (conn, b->ob_oid, LCK_PR, 0, getpagesize (), &lh);
- if (rc != 0) {
- fprintf (stderr, "obdio_barrier "LPX64": Error on PR enqueue: %s\n",
- b->ob_oid, strerror (errno));
- goto out_1;
- }
-
- memset (fileb, 0xeb, getpagesize ());
- rc = obdio_pread (conn, b->ob_oid, (void *)fileb, getpagesize (), 0);
- if (rc != 0) {
- fprintf (stderr, "obdio_barrier "LPX64": Error on read: %s\n",
- b->ob_oid, strerror (errno));
- goto out_2;
- }
-
- if (fileb->ob_id != b->ob_id ||
- fileb->ob_oid != b->ob_oid ||
- fileb->ob_npeers != b->ob_npeers ||
- fileb->ob_count >= b->ob_npeers ||
- (fileb->ob_ordinal != b->ob_ordinal - 1 &&
- fileb->ob_ordinal != b->ob_ordinal)) {
- fprintf (stderr, "obdio_barrier "LPX64": corrupt\n", b->ob_id);
- fprintf (stderr, " got ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n",
- fileb->ob_id, fileb->ob_oid, fileb->ob_npeers,
- fileb->ob_ordinal, fileb->ob_count);
- fprintf (stderr, " expected ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n",
- b->ob_id, b->ob_oid, b->ob_npeers,
- b->ob_ordinal, b->ob_count);
- rc = -1;
- goto out_2;
- }
- }
-
+
+ fileb = fileptr;
+ memset(fileb, 0xeb, getpagesize());
+ rc = obdio_pread(conn, b->ob_oid, fileb, getpagesize(), 0);
+ if (rc != 0) {
+ fprintf(stderr, "%s "LPX64": Error on initial read: %s\n",
+ __FUNCTION__, b->ob_oid, strerror(errno));
+ goto out_2;
+ }
+
+ if (fileb->ob_id != b->ob_id ||
+ fileb->ob_oid != b->ob_oid ||
+ fileb->ob_npeers != b->ob_npeers ||
+ fileb->ob_count >= b->ob_npeers ||
+ fileb->ob_ordinal != b->ob_ordinal) {
+ fprintf(stderr, "%s "LPX64": corrupt on initial read\n",
+ __FUNCTION__, b->ob_id);
+ fprintf(stderr,
+ " got ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n",
+ fileb->ob_id, fileb->ob_oid, fileb->ob_npeers,
+ fileb->ob_ordinal, fileb->ob_count);
+ fprintf(stderr,
+ " expected ["LPX64","LPX64","LPX64","LPX64","LPX64"]\n",
+ b->ob_id, b->ob_oid, b->ob_npeers,
+ b->ob_ordinal, b->ob_count);
+ rc = -1;
+ goto out_2;
+ }
+
+ fileb->ob_count++;
+ if (fileb->ob_count == fileb->ob_npeers) { /* I'm the last joiner */
+ fileb->ob_count = 0; /* join count for next barrier */
+ fileb->ob_ordinal++; /* signal all joined */
+ }
+
+ rc = obdio_pwrite(conn, b->ob_oid, fileb, getpagesize(), 0);
+ if (rc != 0) {
+ fprintf (stderr, "%s "LPX64": Error on initial write: %s\n",
+ __FUNCTION__, b->ob_oid, strerror(errno));
+ goto out_2;
+ }
+
+ mode = "PW";
+ b->ob_ordinal++; /* now I wait... */
+ while (fileb->ob_ordinal != b->ob_ordinal) {
+ rc = obdio_cancel (conn, &lh);
+ if (rc != 0) {
+ fprintf(stderr, "%s "LPX64": Error on %s cancel: %s\n",
+ __FUNCTION__, b->ob_oid, mode, strerror(errno));
+ goto out_1;
+ }
+
+ mode = "PR";
+ rc = obdio_enqueue(conn, b->ob_oid, LCK_PR,0,getpagesize(),&lh);
+ if (rc != 0) {
+ fprintf(stderr, "%s "LPX64": Error on PR enqueue: %s\n",
+ __FUNCTION__, b->ob_oid, strerror(errno));
+ goto out_1;
+ }
+
+ memset (fileb, 0xeb, getpagesize());
+ rc = obdio_pread(conn, b->ob_oid, fileb, getpagesize(), 0);
+ if (rc != 0) {
+ fprintf(stderr, "%s "LPX64": Error on read: %s\n",
+ __FUNCTION__, b->ob_oid, strerror(errno));
+ goto out_2;
+ }
+
+ if (fileb->ob_id != b->ob_id ||
+ fileb->ob_oid != b->ob_oid ||
+ fileb->ob_npeers != b->ob_npeers ||
+ fileb->ob_count >= b->ob_npeers ||
+ (fileb->ob_ordinal != b->ob_ordinal - 1 &&
+ fileb->ob_ordinal != b->ob_ordinal)) {
+ fprintf(stderr, "%s "LPX64": corrupt\n",
+ __FUNCTION__, b->ob_id);
+ fprintf(stderr, " got ["LPX64","LPX64","LPX64","
+ LPX64","LPX64"]\n",
+ fileb->ob_id, fileb->ob_oid, fileb->ob_npeers,
+ fileb->ob_ordinal, fileb->ob_count);
+ fprintf(stderr, " expected ["LPX64","LPX64","LPX64
+ ","LPX64","LPX64"]\n",
+ b->ob_id, b->ob_oid, b->ob_npeers,
+ b->ob_ordinal, b->ob_count);
+ rc = -1;
+ goto out_2;
+ }
+ }
+