Re: [PATCH][FAT] FAT dirent scan with hin take #3

Pekka Enberg
2005-08-31T13:53:47Z

On 8/31/05, Pekka Enberg <penberg@cs.helsinki.fi> wrote:
> After finally understanding what you're doing, how about:
>
> static inline int hint_allocate(struct inode *dir)
> {
> loff_t *hints;
> int err = 0;
>
> if (!MSDOS_I(dir)->scan_hints)

Should read:

if (MSDOS_I(dir)->scan_hints)

> return 0;
>
> hints = kcalloc(FAT_SCAN_NWAY, sizeof(loff_t), GFP_KERNEL);
> if (!hints)
> err = -ENOMEM;
>
> down(&MSDOS_I(dir)->scan_lock);
> /*
> * We allocated memory without scan_lock so lets make sure
> * no other thread completed hint_allocate() before us.
> */
> if (!MSDOS_I(dir)->scan_hints) {
> MSDOS_I(dir)->scan_hints = hints;
> hints = NULL;
> }
> up(&MSDOS_I(dir)->scan_lock);
>
> kfree(hints);
> return err;
> }
>
> Pekka
>