void *hpfs_get_4sectors(struct super_block *s, unsigned secno, struct quad_buffer_head *qbh) { cond_resched(); if (secno & 3) { printk("HPFS: hpfs_get_4sectors: unaligned read\n"); return NULL; } /*return hpfs_map_4sectors(s, secno, qbh, 0);*/ if (!(qbh->data = kmalloc(2048, GFP_NOFS))) { printk("HPFS: hpfs_get_4sectors: out of memory\n"); return NULL; } if (!(hpfs_get_sector(s, secno, &qbh->bh[0]))) goto bail0; if (!(hpfs_get_sector(s, secno + 1, &qbh->bh[1]))) goto bail1; if (!(hpfs_get_sector(s, secno + 2, &qbh->bh[2]))) goto bail2; if (!(hpfs_get_sector(s, secno + 3, &qbh->bh[3]))) goto bail3; memcpy(qbh->data, qbh->bh[0]->b_data, 512); memcpy(qbh->data + 512, qbh->bh[1]->b_data, 512); memcpy(qbh->data + 2*512, qbh->bh[2]->b_data, 512); memcpy(qbh->data + 3*512, qbh->bh[3]->b_data, 512); return qbh->data; bail3: brelse(qbh->bh[2]); bail2: brelse(qbh->bh[1]); bail1: brelse(qbh->bh[0]); bail0: return NULL; }
void *hpfs_get_4sectors(struct super_block *s, unsigned secno, struct quad_buffer_head *qbh) { cond_resched(); hpfs_lock_assert(s); if (secno & 3) { pr_err("%s(): unaligned read\n", __func__); return NULL; } if (!hpfs_get_sector(s, secno + 0, &qbh->bh[0])) goto bail0; if (!hpfs_get_sector(s, secno + 1, &qbh->bh[1])) goto bail1; if (!hpfs_get_sector(s, secno + 2, &qbh->bh[2])) goto bail2; if (!hpfs_get_sector(s, secno + 3, &qbh->bh[3])) goto bail3; if (likely(qbh->bh[1]->b_data == qbh->bh[0]->b_data + 1 * 512) && likely(qbh->bh[2]->b_data == qbh->bh[0]->b_data + 2 * 512) && likely(qbh->bh[3]->b_data == qbh->bh[0]->b_data + 3 * 512)) { return qbh->data = qbh->bh[0]->b_data; } if (!(qbh->data = kmalloc(2048, GFP_NOFS))) { pr_err("%s(): out of memory\n", __func__); goto bail4; } return qbh->data; bail4: brelse(qbh->bh[3]); bail3: brelse(qbh->bh[2]); bail2: brelse(qbh->bh[1]); bail1: brelse(qbh->bh[0]); bail0: return NULL; }