Skip to content

Commit db57044

Browse files
author
Al Viro
committed
ufs: get rid of ubh_{ubhcpymem,memcpyubh}()
used only in ufs_read_cylinder_structures()/ufs_put_super_internal() and there we can just as well avoid bothering with ufs_buffer_head and just deal with it fragment-by-fragment. Signed-off-by: Al Viro <[email protected]>
1 parent ae79ce9 commit db57044

File tree

3 files changed

+17
-79
lines changed

3 files changed

+17
-79
lines changed

fs/ufs/super.c

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
505505
{
506506
struct ufs_sb_info *sbi = UFS_SB(sb);
507507
struct ufs_sb_private_info *uspi = sbi->s_uspi;
508-
struct ufs_buffer_head * ubh;
509508
unsigned char * base, * space;
510509
unsigned size, blks, i;
511510

@@ -521,21 +520,13 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
521520
if (!base)
522521
goto failed;
523522
sbi->s_csp = (struct ufs_csum *)space;
524-
for (i = 0; i < blks; i += uspi->s_fpb) {
525-
size = uspi->s_bsize;
526-
if (i + uspi->s_fpb > blks)
527-
size = (blks - i) * uspi->s_fsize;
528-
529-
ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
530-
531-
if (!ubh)
523+
for (i = 0; i < blks; i++) {
524+
struct buffer_head *bh = sb_bread(sb, uspi->s_csaddr + i);
525+
if (!bh)
532526
goto failed;
533-
534-
ubh_ubhcpymem (space, ubh, size);
535-
536-
space += size;
537-
ubh_brelse (ubh);
538-
ubh = NULL;
527+
memcpy(space, bh->b_data, uspi->s_fsize);
528+
space += uspi->s_fsize;
529+
brelse (bh);
539530
}
540531

541532
/*
@@ -645,7 +636,6 @@ static void ufs_put_super_internal(struct super_block *sb)
645636
{
646637
struct ufs_sb_info *sbi = UFS_SB(sb);
647638
struct ufs_sb_private_info *uspi = sbi->s_uspi;
648-
struct ufs_buffer_head * ubh;
649639
unsigned char * base, * space;
650640
unsigned blks, size, i;
651641

@@ -656,18 +646,17 @@ static void ufs_put_super_internal(struct super_block *sb)
656646
size = uspi->s_cssize;
657647
blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift;
658648
base = space = (char*) sbi->s_csp;
659-
for (i = 0; i < blks; i += uspi->s_fpb) {
660-
size = uspi->s_bsize;
661-
if (i + uspi->s_fpb > blks)
662-
size = (blks - i) * uspi->s_fsize;
663-
664-
ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
665-
666-
ubh_memcpyubh (ubh, space, size);
667-
space += size;
668-
ubh_mark_buffer_uptodate (ubh, 1);
669-
ubh_mark_buffer_dirty (ubh);
670-
ubh_brelse (ubh);
649+
for (i = 0; i < blks; i++, space += uspi->s_fsize) {
650+
struct buffer_head *bh = sb_bread(sb, uspi->s_csaddr + i);
651+
652+
if (unlikely(!bh)) { // better than an oops...
653+
ufs_panic(sb, __func__,
654+
"can't write part of cylinder group summary");
655+
continue;
656+
}
657+
memcpy(bh->b_data, space, uspi->s_fsize);
658+
mark_buffer_dirty(bh);
659+
brelse(bh);
671660
}
672661
for (i = 0; i < sbi->s_cg_loaded; i++) {
673662
ufs_put_cylinder (sb, i);

fs/ufs/util.c

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,6 @@ void ubh_mark_buffer_dirty (struct ufs_buffer_head * ubh)
9999
mark_buffer_dirty (ubh->bh[i]);
100100
}
101101

102-
void ubh_mark_buffer_uptodate (struct ufs_buffer_head * ubh, int flag)
103-
{
104-
unsigned i;
105-
if (!ubh)
106-
return;
107-
if (flag) {
108-
for ( i = 0; i < ubh->count; i++ )
109-
set_buffer_uptodate (ubh->bh[i]);
110-
} else {
111-
for ( i = 0; i < ubh->count; i++ )
112-
clear_buffer_uptodate (ubh->bh[i]);
113-
}
114-
}
115-
116102
void ubh_sync_block(struct ufs_buffer_head *ubh)
117103
{
118104
if (ubh) {
@@ -146,38 +132,6 @@ int ubh_buffer_dirty (struct ufs_buffer_head * ubh)
146132
return result;
147133
}
148134

149-
void _ubh_ubhcpymem_(struct ufs_sb_private_info * uspi,
150-
unsigned char * mem, struct ufs_buffer_head * ubh, unsigned size)
151-
{
152-
unsigned len, bhno;
153-
if (size > (ubh->count << uspi->s_fshift))
154-
size = ubh->count << uspi->s_fshift;
155-
bhno = 0;
156-
while (size) {
157-
len = min_t(unsigned int, size, uspi->s_fsize);
158-
memcpy (mem, ubh->bh[bhno]->b_data, len);
159-
mem += uspi->s_fsize;
160-
size -= len;
161-
bhno++;
162-
}
163-
}
164-
165-
void _ubh_memcpyubh_(struct ufs_sb_private_info * uspi,
166-
struct ufs_buffer_head * ubh, unsigned char * mem, unsigned size)
167-
{
168-
unsigned len, bhno;
169-
if (size > (ubh->count << uspi->s_fshift))
170-
size = ubh->count << uspi->s_fshift;
171-
bhno = 0;
172-
while (size) {
173-
len = min_t(unsigned int, size, uspi->s_fsize);
174-
memcpy (ubh->bh[bhno]->b_data, mem, len);
175-
mem += uspi->s_fsize;
176-
size -= len;
177-
bhno++;
178-
}
179-
}
180-
181135
dev_t
182136
ufs_get_inode_dev(struct super_block *sb, struct ufs_inode_info *ufsi)
183137
{

fs/ufs/util.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,9 @@ extern struct ufs_buffer_head * ubh_bread_uspi(struct ufs_sb_private_info *, str
263263
extern void ubh_brelse (struct ufs_buffer_head *);
264264
extern void ubh_brelse_uspi (struct ufs_sb_private_info *);
265265
extern void ubh_mark_buffer_dirty (struct ufs_buffer_head *);
266-
extern void ubh_mark_buffer_uptodate (struct ufs_buffer_head *, int);
267266
extern void ubh_sync_block(struct ufs_buffer_head *);
268267
extern void ubh_bforget (struct ufs_buffer_head *);
269268
extern int ubh_buffer_dirty (struct ufs_buffer_head *);
270-
#define ubh_ubhcpymem(mem,ubh,size) _ubh_ubhcpymem_(uspi,mem,ubh,size)
271-
extern void _ubh_ubhcpymem_(struct ufs_sb_private_info *, unsigned char *, struct ufs_buffer_head *, unsigned);
272-
#define ubh_memcpyubh(ubh,mem,size) _ubh_memcpyubh_(uspi,ubh,mem,size)
273-
extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head *, unsigned char *, unsigned);
274269

275270
/* This functions works with cache pages*/
276271
struct folio *ufs_get_locked_folio(struct address_space *mapping, pgoff_t index);

0 commit comments

Comments
 (0)