Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\badblocks.c Create Date:2022-07-28 17:24:23
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:adblocks_set() - Add a range of bad blocks to the table

Proto:int badblocks_set(struct badblocks *bb, sector_t s, int sectors, int acknowledged)

Type:int

Parameter:

TypeParameterName
struct badblocks *bb
sector_ts
intsectors
intacknowledged
168  rv = 0
171  If shift from sectors to block size * a -ve shift means badblocks are * disabled. < 0 Then Return 1
175  If shift from sectors to block size * a -ve shift means badblocks are * disabled. Then
177  next = s + sectors
179  s >>= shift from sectors to block size * a -ve shift means badblocks are * disabled.
180  next += (1 << shift from sectors to block size * a -ve shift means badblocks are * disabled.) - 1
181  next >>= shift from sectors to block size * a -ve shift means badblocks are * disabled.
182  sectors = next - s
185  write_seqlock_irqsave( & lock, flags)
187  p = badblock list
188  lo = 0
189  hi = count of bad blocks
191  When hi - lo > 1 cycle
192  mid = (lo + hi) / 2
193  a = BB_OFFSET(p[mid])
195  If a <= s Then lo = mid
197  Else hi = mid
200  If hi > lo && BB_OFFSET(p[lo]) > s Then hi = lo
203  If hi > lo Then
207  a = BB_OFFSET(p[lo])
208  e = a + BB_LEN(p[lo])
209  ack = BB_ACK(p[lo])
211  If e >= s Then
213  If s == a && s + sectors >= e Then ack = acknowledged
216  Else ack = ack && acknowledged
219  If e < s + sectors Then e = s + sectors
221  If e - a <= BB_MAX_LEN Then
222  p[lo] = BB_MAKE(a, e - a, ack)
223  s = e
224  Else
228  If BB_LEN(p[lo]) != BB_MAX_LEN Then p[lo] = BB_MAKE(a, BB_MAX_LEN, ack)
230  s = a + BB_MAX_LEN
232  sectors = e - s
235  If sectors && hi < count of bad blocks Then
239  a = BB_OFFSET(p[hi])
240  e = a + BB_LEN(p[hi])
241  ack = BB_ACK(p[hi])
243  If a <= s + sectors Then
245  If e <= s + sectors Then
247  e = s + sectors
248  ack = acknowledged
249  Else ack = ack && acknowledged
252  a = s
253  If e - a <= BB_MAX_LEN Then
254  p[hi] = BB_MAKE(a, e - a, ack)
255  s = e
256  Else
257  p[hi] = BB_MAKE(a, BB_MAX_LEN, ack)
258  s = a + BB_MAX_LEN
260  sectors = e - s
261  lo = hi
262  hi++
265  If sectors == 0 && hi < count of bad blocks Then
268  a = BB_OFFSET(p[hi])
269  lolen = BB_LEN(p[lo])
270  hilen = BB_LEN(p[hi])
271  newlen = lolen + hilen - s - a
273  If s >= a && newlen < BB_MAX_LEN Then
275  ack = BB_ACK(p[lo]) && BB_ACK(p[hi])
277  p[lo] = BB_MAKE(BB_OFFSET(p[lo]), newlen, ack)
283  When sectors cycle
289  rv = 1
290  Break
291  Else
294  memmove(p + hi + 1, p + hi, ( count of bad blocks - hi) * 8)
302  s += this_sectors
306  changed = 1
307  If Not acknowledged Then there probably are unacknowledged * bad blocks. This is only cleared * when a read discovers none = 1
309  Else badblocks_update_acked(bb)
311  write_sequnlock_irqrestore( & lock, flags)
313  Return rv
Caller
NameDescribe
badblocks_storeadblocks_store() - sysfs access to bad-blocks list*@bb: the badblocks structure that holds all badblock information*@page: buffer received from sysfs*@len: length of data received from sysfs*@unack: weather to show unacknowledged badblocks* Return: