buffer.c (1749a10e02a9c6ed1a5c0a2860fb9ed132f2cc42) | buffer.c (a19189e5535ed8fd191d8989fc39da1637cfa224) |
---|---|
1/* 2 * linux/fs/hpfs/buffer.c 3 * 4 * Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999 5 * 6 * general buffer i/o 7 */ 8#include <linux/sched.h> --- 41 unchanged lines hidden (view full) --- 50 hpfs_prefetch_sectors(s, secno, ahead); 51 52 cond_resched(); 53 54 *bhp = bh = sb_bread(s, secno); 55 if (bh != NULL) 56 return bh->b_data; 57 else { | 1/* 2 * linux/fs/hpfs/buffer.c 3 * 4 * Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999 5 * 6 * general buffer i/o 7 */ 8#include <linux/sched.h> --- 41 unchanged lines hidden (view full) --- 50 hpfs_prefetch_sectors(s, secno, ahead); 51 52 cond_resched(); 53 54 *bhp = bh = sb_bread(s, secno); 55 if (bh != NULL) 56 return bh->b_data; 57 else { |
58 pr_warn("%s(): read error\n", __func__); | 58 pr_err("%s(): read error\n", __func__); |
59 return NULL; 60 } 61} 62 63/* Like hpfs_map_sector but don't read anything */ 64 65void *hpfs_get_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp) 66{ --- 4 unchanged lines hidden (view full) --- 71 72 cond_resched(); 73 74 if ((*bhp = bh = sb_getblk(s, secno)) != NULL) { 75 if (!buffer_uptodate(bh)) wait_on_buffer(bh); 76 set_buffer_uptodate(bh); 77 return bh->b_data; 78 } else { | 59 return NULL; 60 } 61} 62 63/* Like hpfs_map_sector but don't read anything */ 64 65void *hpfs_get_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp) 66{ --- 4 unchanged lines hidden (view full) --- 71 72 cond_resched(); 73 74 if ((*bhp = bh = sb_getblk(s, secno)) != NULL) { 75 if (!buffer_uptodate(bh)) wait_on_buffer(bh); 76 set_buffer_uptodate(bh); 77 return bh->b_data; 78 } else { |
79 pr_warn("%s(): getblk failed\n", __func__); | 79 pr_err("%s(): getblk failed\n", __func__); |
80 return NULL; 81 } 82} 83 84/* Map 4 sectors into a 4buffer and return pointers to it and to the buffer. */ 85 86void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffer_head *qbh, 87 int ahead) 88{ 89 char *data; 90 91 hpfs_lock_assert(s); 92 93 cond_resched(); 94 95 if (secno & 3) { | 80 return NULL; 81 } 82} 83 84/* Map 4 sectors into a 4buffer and return pointers to it and to the buffer. */ 85 86void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffer_head *qbh, 87 int ahead) 88{ 89 char *data; 90 91 hpfs_lock_assert(s); 92 93 cond_resched(); 94 95 if (secno & 3) { |
96 pr_warn("%s(): unaligned read\n", __func__); | 96 pr_err("%s(): unaligned read\n", __func__); |
97 return NULL; 98 } 99 100 hpfs_prefetch_sectors(s, secno, 4 + ahead); 101 102 if (!(qbh->bh[0] = sb_bread(s, secno + 0))) goto bail0; 103 if (!(qbh->bh[1] = sb_bread(s, secno + 1))) goto bail1; 104 if (!(qbh->bh[2] = sb_bread(s, secno + 2))) goto bail2; 105 if (!(qbh->bh[3] = sb_bread(s, secno + 3))) goto bail3; 106 107 if (likely(qbh->bh[1]->b_data == qbh->bh[0]->b_data + 1 * 512) && 108 likely(qbh->bh[2]->b_data == qbh->bh[0]->b_data + 2 * 512) && 109 likely(qbh->bh[3]->b_data == qbh->bh[0]->b_data + 3 * 512)) { 110 return qbh->data = qbh->bh[0]->b_data; 111 } 112 113 qbh->data = data = kmalloc(2048, GFP_NOFS); 114 if (!data) { | 97 return NULL; 98 } 99 100 hpfs_prefetch_sectors(s, secno, 4 + ahead); 101 102 if (!(qbh->bh[0] = sb_bread(s, secno + 0))) goto bail0; 103 if (!(qbh->bh[1] = sb_bread(s, secno + 1))) goto bail1; 104 if (!(qbh->bh[2] = sb_bread(s, secno + 2))) goto bail2; 105 if (!(qbh->bh[3] = sb_bread(s, secno + 3))) goto bail3; 106 107 if (likely(qbh->bh[1]->b_data == qbh->bh[0]->b_data + 1 * 512) && 108 likely(qbh->bh[2]->b_data == qbh->bh[0]->b_data + 2 * 512) && 109 likely(qbh->bh[3]->b_data == qbh->bh[0]->b_data + 3 * 512)) { 110 return qbh->data = qbh->bh[0]->b_data; 111 } 112 113 qbh->data = data = kmalloc(2048, GFP_NOFS); 114 if (!data) { |
115 pr_warn("%s(): out of memory\n", __func__); | 115 pr_err("%s(): out of memory\n", __func__); |
116 goto bail4; 117 } 118 119 memcpy(data + 0 * 512, qbh->bh[0]->b_data, 512); 120 memcpy(data + 1 * 512, qbh->bh[1]->b_data, 512); 121 memcpy(data + 2 * 512, qbh->bh[2]->b_data, 512); 122 memcpy(data + 3 * 512, qbh->bh[3]->b_data, 512); 123 --- 16 unchanged lines hidden (view full) --- 140void *hpfs_get_4sectors(struct super_block *s, unsigned secno, 141 struct quad_buffer_head *qbh) 142{ 143 cond_resched(); 144 145 hpfs_lock_assert(s); 146 147 if (secno & 3) { | 116 goto bail4; 117 } 118 119 memcpy(data + 0 * 512, qbh->bh[0]->b_data, 512); 120 memcpy(data + 1 * 512, qbh->bh[1]->b_data, 512); 121 memcpy(data + 2 * 512, qbh->bh[2]->b_data, 512); 122 memcpy(data + 3 * 512, qbh->bh[3]->b_data, 512); 123 --- 16 unchanged lines hidden (view full) --- 140void *hpfs_get_4sectors(struct super_block *s, unsigned secno, 141 struct quad_buffer_head *qbh) 142{ 143 cond_resched(); 144 145 hpfs_lock_assert(s); 146 147 if (secno & 3) { |
148 pr_warn("%s(): unaligned read\n", __func__); | 148 pr_err("%s(): unaligned read\n", __func__); |
149 return NULL; 150 } 151 152 if (!hpfs_get_sector(s, secno + 0, &qbh->bh[0])) goto bail0; 153 if (!hpfs_get_sector(s, secno + 1, &qbh->bh[1])) goto bail1; 154 if (!hpfs_get_sector(s, secno + 2, &qbh->bh[2])) goto bail2; 155 if (!hpfs_get_sector(s, secno + 3, &qbh->bh[3])) goto bail3; 156 157 if (likely(qbh->bh[1]->b_data == qbh->bh[0]->b_data + 1 * 512) && 158 likely(qbh->bh[2]->b_data == qbh->bh[0]->b_data + 2 * 512) && 159 likely(qbh->bh[3]->b_data == qbh->bh[0]->b_data + 3 * 512)) { 160 return qbh->data = qbh->bh[0]->b_data; 161 } 162 163 if (!(qbh->data = kmalloc(2048, GFP_NOFS))) { | 149 return NULL; 150 } 151 152 if (!hpfs_get_sector(s, secno + 0, &qbh->bh[0])) goto bail0; 153 if (!hpfs_get_sector(s, secno + 1, &qbh->bh[1])) goto bail1; 154 if (!hpfs_get_sector(s, secno + 2, &qbh->bh[2])) goto bail2; 155 if (!hpfs_get_sector(s, secno + 3, &qbh->bh[3])) goto bail3; 156 157 if (likely(qbh->bh[1]->b_data == qbh->bh[0]->b_data + 1 * 512) && 158 likely(qbh->bh[2]->b_data == qbh->bh[0]->b_data + 2 * 512) && 159 likely(qbh->bh[3]->b_data == qbh->bh[0]->b_data + 3 * 512)) { 160 return qbh->data = qbh->bh[0]->b_data; 161 } 162 163 if (!(qbh->data = kmalloc(2048, GFP_NOFS))) { |
164 pr_warn("%s(): out of memory\n", __func__); | 164 pr_err("%s(): out of memory\n", __func__); |
165 goto bail4; 166 } 167 return qbh->data; 168 169bail4: 170 brelse(qbh->bh[3]); 171bail3: 172 brelse(qbh->bh[2]); --- 32 unchanged lines hidden --- | 165 goto bail4; 166 } 167 return qbh->data; 168 169bail4: 170 brelse(qbh->bh[3]); 171bail3: 172 brelse(qbh->bh[2]); --- 32 unchanged lines hidden --- |