Annotation of 42BSD/ingres/source/iutil/page.c, revision 1.1.1.1

1.1       root        1: # include      <ingres.h>
                      2: # include      <access.h>
                      3: # include      <aux.h>
                      4: # include      <lock.h>
                      5: # include      <sccs.h>
                      6: 
                      7: SCCSID(@(#)page.c      7.1     2/5/81)
                      8: 
                      9: /*
                     10: **     UNIX read/write counters
                     11: */
                     12: 
                     13: long   Accuread, Accuwrite;
                     14: long   Accusread;
                     15: 
                     16: /*
                     17: **  GETPAGE
                     18: **
                     19: **     Trace Flags:
                     20: **             26
                     21: */
                     22: 
                     23: get_page(d, tid)
                     24: register DESC  *d;
                     25: TID            *tid;
                     26: {
                     27:        register int            i;
                     28:        long                    pageid;
                     29:        register struct accbuf  *b;
                     30:        struct accbuf           *b1;
                     31:        int                     lk;             /* lock condition*/
                     32:        extern struct accbuf    *choose_buf();
                     33:        extern long             lseek();
                     34: 
                     35: #      ifdef xATR3
                     36:        if (tTf(26, 9))
                     37:        {
                     38:                printf("GET_PAGE: %.14s,", d->reldum.relid);
                     39:                dumptid(tid);
                     40:        }
                     41: #      endif
                     42: 
                     43:        pluck_page(tid, &pageid);
                     44:        if ((b = choose_buf(d, pageid)) == NULL)
                     45:                return (-1);
                     46:        top_acc(b);
                     47:        lk = Acclock && (d->reldum.relstat & S_CONCUR) && (d->relopn < 0);
                     48:        if ((b->thispage != pageid) || (lk && !(b->bufstatus & BUF_LOCKED)))
                     49:        {
                     50:                if (i = pageflush(b))
                     51:                        return (i);
                     52: #              ifdef xATR1
                     53:                if (tTf(26, 10))
                     54:                {
                     55:                        printf("GET_PAGE: rdg pg %ld", pageid);
                     56:                        printf(",relid ");
                     57:                        dumptid((TID *) &d->reltid);
                     58:                }
                     59: #              endif
                     60:                b->thispage = pageid;
                     61:                if (lk)
                     62:                {
                     63:                        b1 = Acc_head;
                     64:                        for (; b1 != 0; b1 = b1->modf)
                     65:                                if (b1->bufstatus & BUF_LOCKED)
                     66:                                        pageflush(b1);  /*  */
                     67:                        if (setpgl(b) < 0)
                     68:                                syserr("get-page: lk err");
                     69:                }
                     70: #              ifdef xATM
                     71:                if (tTf(76, 1))
                     72:                        timtrace(17, &pageid, &d->reltid.ltid);
                     73: #              endif
                     74:                if ((lseek(d->relfp, (long)(pageid * PGSIZE), 0) == -1) ||
                     75:                    (read(d->relfp, (char *) b, PGSIZE) != PGSIZE))
                     76:                {
                     77:                        resetacc(b);
                     78:                        return (acc_err(AMREAD_ERR));
                     79:                }
                     80:                Accuread++;
                     81:                if (d->reldum.relstat & S_CATALOG)
                     82:                {
                     83:                        Accusread++;
                     84:                }
                     85: #              ifdef xATM
                     86:                if (tTf(76, 1))
                     87:                        timtrace(18, &pageid, &d->reltid.ltid);
                     88: #              endif
                     89:        }
                     90:        return (0);
                     91: }
                     92: /*
                     93: **  PAGEFLUSH
                     94: **
                     95: **     Trace Flags:
                     96: **             29.2-3
                     97: */
                     98: 
                     99: pageflush(buf)
                    100: struct accbuf  *buf;
                    101: {
                    102:        register struct accbuf  *b;
                    103:        register int            allbufs;
                    104:        int                     err;
                    105: 
                    106:        b = buf;
                    107: #      ifdef xATR3
                    108:        if (tTf(29, 2))
                    109:        {
                    110:                printf("PAGEFLUSH: %x=", b);
                    111:                if (b != NULL)
                    112:                        dumptid(&b->rel_tupid);
                    113:                else
                    114:                        printf("all\n");
                    115:        }
                    116: #      endif
                    117:        err = FALSE;
                    118:        allbufs = FALSE;
                    119:        if (b == 0)
                    120:        {
                    121:                b = Acc_buf;
                    122:                allbufs = TRUE;
                    123:        }
                    124: 
                    125:        do
                    126:        {
                    127:                if (b->bufstatus & BUF_DIRTY)
                    128:                {
                    129: #                      ifdef xATR1
                    130:                        if (tTf(29, 3))
                    131:                        {
                    132:                                printf("PAGEFLUSH: wr pg %ld", b->thispage);
                    133:                                printf(",stat %d,relid ", b->bufstatus);
                    134:                                dumptid((TID *) &b->rel_tupid);
                    135:                        }
                    136: #                      endif
                    137: 
                    138: #                      ifdef xATM
                    139:                        if (tTf(76, 1))
                    140:                                timtrace(19, &b->thispage, &b->rel_tupid);
                    141: #                      endif
                    142: 
                    143:                        b->bufstatus &= ~BUF_DIRTY;
                    144:                        if ((lseek(b->filedesc, (long)(b->thispage * PGSIZE), 0)== -1) ||
                    145:                            (write(b->filedesc, (char *) b, PGSIZE) != PGSIZE))
                    146:                        {
                    147:                                resetacc(b);
                    148:                                err = TRUE;
                    149:                        }
                    150:                        Accuwrite++;
                    151: 
                    152: #                      ifdef xATM
                    153:                        if (tTf(76, 1))
                    154:                                timtrace(20, &b->thispage, &b->rel_tupid);
                    155: #                      endif
                    156:                }
                    157:                if (Acclock && b->bufstatus & BUF_LOCKED)
                    158:                        unlpg(b);
                    159: 
                    160:        } while (allbufs && (b = b->modf) != NULL);
                    161: 
                    162:        if (err)
                    163:                return (acc_err(AMWRITE_ERR));
                    164: 
                    165:        return (0);
                    166: }
                    167: /*
                    168: **  ACC_ERR -- set global error indicator "Accerror"
                    169: **
                    170: **     Trace Flags:
                    171: **             20.4-5
                    172: */
                    173: 
                    174: acc_err(errnum)
                    175: int    errnum;
                    176: {
                    177:        Accerror = errnum;
                    178: #      ifdef xATR1
                    179:        tTfp(20, 4, "ACC_ERR: %d\n", Accerror);
                    180: #      endif
                    181:        return (Accerror);
                    182: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.