Re: Reading disks sectors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




mm/page_io.c

static struct bio *get_swap_bio(gfp_t gfp_flags,
                                struct page *page, bio_end_io_t end_io)
{
        bio = bio_alloc(gfp_flags, 1);
        if (bio) {
                bio->bi_iter.bi_sector = map_swap_page(page, &bio->bi_bdev);
                bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9;
                bio->bi_iter.bi_size = PAGE_SIZE;
                bio->bi_end_io = end_io;
        }
        return bio;
}


bi_endio() calls bio->bi_end_io. One should assign a routine to bio->bi_end_io.
One can wake up the thread waiting for IO in bi_end_io. For example: direct IO
has assigned dio_bio_end_io routine to bio->bi_end_io

fs/direct-io.c

/*
 * The BIO completion handler simply queues the BIO up for the process-context
 * handler.
 *
 * During I/O bi_private points at the dio.  After I/O, bi_private is used to
 * implement a singly-linked list of completed BIOs, at dio->bio_list.
 */
static void dio_bio_end_io(struct bio *bio, int error)
{
        struct dio *dio = bio->bi_private;
       
        bio->bi_private = dio->bio_list;
        dio->bio_list = bio;
        if (--dio->refcount == 1 && dio->waiter)
                wake_up_process(dio->waiter);
}


Regards
Manoj Nayak
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux