~ubuntu-branches/ubuntu/saucy/linux-ti-omap4/saucy-proposed

« back to all changes in this revision

Viewing changes to fs/gfs2/log.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Stefan Bader, Upstream Kernel Changes
  • Date: 2012-08-15 17:17:43 UTC
  • Revision ID: package-import@ubuntu.com-20120815171743-h5wnuf51xe7pvdid
Tags: 3.5.0-207.13
[ Paolo Pisati ]

* Start new release

[ Stefan Bader ]

* (config) Enable getabis to use local package copies

[ Upstream Kernel Changes ]

* fixup: gargabe collect iva_seq[0|1] init
* [Config] enable all SND_OMAP_SOC_*s
* fixup: cm2xxx_3xxx.o is needed for omap2_cm_read|write_reg
* fixup: add some snd_soc_dai* helper functions
* fixup: s/snd_soc_dpcm_params/snd_soc_dpcm/g
* fixup: typo, no_host_mode and useless SDP4430 init
* fixup: enable again aess hwmod

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "dir.h"
33
33
#include "trace_gfs2.h"
34
34
 
35
 
#define PULL 1
36
 
 
37
35
/**
38
36
 * gfs2_struct2blk - compute stuff
39
37
 * @sdp: the filesystem
359
357
        return 0;
360
358
}
361
359
 
362
 
u64 gfs2_log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
363
 
{
364
 
        struct gfs2_journal_extent *je;
365
 
 
366
 
        list_for_each_entry(je, &sdp->sd_jdesc->extent_list, extent_list) {
367
 
                if (lbn >= je->lblock && lbn < je->lblock + je->blocks)
368
 
                        return je->dblock + lbn - je->lblock;
369
 
        }
370
 
 
371
 
        return -1;
372
 
}
373
 
 
374
360
/**
375
361
 * log_distance - Compute distance between two journal blocks
376
362
 * @sdp: The GFS2 superblock
466
452
        return tail;
467
453
}
468
454
 
469
 
void gfs2_log_incr_head(struct gfs2_sbd *sdp)
470
 
{
471
 
        BUG_ON((sdp->sd_log_flush_head == sdp->sd_log_tail) &&
472
 
               (sdp->sd_log_flush_head != sdp->sd_log_head));
473
 
 
474
 
        if (++sdp->sd_log_flush_head == sdp->sd_jdesc->jd_blocks) {
475
 
                sdp->sd_log_flush_head = 0;
476
 
                sdp->sd_log_flush_wrapped = 1;
477
 
        }
478
 
}
479
 
 
480
455
static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail)
481
456
{
482
457
        unsigned int dist = log_distance(sdp, new_tail, sdp->sd_log_tail);
511
486
{
512
487
        struct gfs2_bufdata *bda, *bdb;
513
488
 
514
 
        bda = list_entry(a, struct gfs2_bufdata, bd_le.le_list);
515
 
        bdb = list_entry(b, struct gfs2_bufdata, bd_le.le_list);
 
489
        bda = list_entry(a, struct gfs2_bufdata, bd_list);
 
490
        bdb = list_entry(b, struct gfs2_bufdata, bd_list);
516
491
 
517
492
        if (bda->bd_bh->b_blocknr < bdb->bd_bh->b_blocknr)
518
493
                return -1;
530
505
        gfs2_log_lock(sdp);
531
506
        list_sort(NULL, &sdp->sd_log_le_ordered, &bd_cmp);
532
507
        while (!list_empty(&sdp->sd_log_le_ordered)) {
533
 
                bd = list_entry(sdp->sd_log_le_ordered.next, struct gfs2_bufdata, bd_le.le_list);
534
 
                list_move(&bd->bd_le.le_list, &written);
 
508
                bd = list_entry(sdp->sd_log_le_ordered.next, struct gfs2_bufdata, bd_list);
 
509
                list_move(&bd->bd_list, &written);
535
510
                bh = bd->bd_bh;
536
511
                if (!buffer_dirty(bh))
537
512
                        continue;
558
533
 
559
534
        gfs2_log_lock(sdp);
560
535
        while (!list_empty(&sdp->sd_log_le_ordered)) {
561
 
                bd = list_entry(sdp->sd_log_le_ordered.prev, struct gfs2_bufdata, bd_le.le_list);
 
536
                bd = list_entry(sdp->sd_log_le_ordered.prev, struct gfs2_bufdata, bd_list);
562
537
                bh = bd->bd_bh;
563
538
                if (buffer_locked(bh)) {
564
539
                        get_bh(bh);
568
543
                        gfs2_log_lock(sdp);
569
544
                        continue;
570
545
                }
571
 
                list_del_init(&bd->bd_le.le_list);
 
546
                list_del_init(&bd->bd_list);
572
547
        }
573
548
        gfs2_log_unlock(sdp);
574
549
}
580
555
 * Returns: the initialized log buffer descriptor
581
556
 */
582
557
 
583
 
static void log_write_header(struct gfs2_sbd *sdp, u32 flags, int pull)
 
558
static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
584
559
{
585
 
        u64 blkno = gfs2_log_bmap(sdp, sdp->sd_log_flush_head);
586
 
        struct buffer_head *bh;
587
560
        struct gfs2_log_header *lh;
588
561
        unsigned int tail;
589
562
        u32 hash;
590
 
 
591
 
        bh = sb_getblk(sdp->sd_vfs, blkno);
592
 
        lock_buffer(bh);
593
 
        memset(bh->b_data, 0, bh->b_size);
594
 
        set_buffer_uptodate(bh);
595
 
        clear_buffer_dirty(bh);
 
563
        int rw = WRITE_FLUSH_FUA | REQ_META;
 
564
        struct page *page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
 
565
        lh = page_address(page);
 
566
        clear_page(lh);
596
567
 
597
568
        gfs2_ail1_empty(sdp);
598
569
        tail = current_tail(sdp);
599
570
 
600
 
        lh = (struct gfs2_log_header *)bh->b_data;
601
 
        memset(lh, 0, sizeof(struct gfs2_log_header));
602
571
        lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
603
572
        lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH);
604
573
        lh->lh_header.__pad0 = cpu_to_be64(0);
608
577
        lh->lh_flags = cpu_to_be32(flags);
609
578
        lh->lh_tail = cpu_to_be32(tail);
610
579
        lh->lh_blkno = cpu_to_be32(sdp->sd_log_flush_head);
611
 
        hash = gfs2_disk_hash(bh->b_data, sizeof(struct gfs2_log_header));
 
580
        hash = gfs2_disk_hash(page_address(page), sizeof(struct gfs2_log_header));
612
581
        lh->lh_hash = cpu_to_be32(hash);
613
582
 
614
 
        bh->b_end_io = end_buffer_write_sync;
615
 
        get_bh(bh);
616
583
        if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) {
617
584
                gfs2_ordered_wait(sdp);
618
585
                log_flush_wait(sdp);
619
 
                submit_bh(WRITE_SYNC | REQ_META | REQ_PRIO, bh);
620
 
        } else {
621
 
                submit_bh(WRITE_FLUSH_FUA | REQ_META, bh);
 
586
                rw = WRITE_SYNC | REQ_META | REQ_PRIO;
622
587
        }
623
 
        wait_on_buffer(bh);
624
588
 
625
 
        if (!buffer_uptodate(bh))
626
 
                gfs2_io_error_bh(sdp, bh);
627
 
        brelse(bh);
 
589
        sdp->sd_log_idle = (tail == sdp->sd_log_flush_head);
 
590
        gfs2_log_write_page(sdp, page);
 
591
        gfs2_log_flush_bio(sdp, rw);
 
592
        log_flush_wait(sdp);
628
593
 
629
594
        if (sdp->sd_log_tail != tail)
630
595
                log_pull_tail(sdp, tail);
631
 
        else
632
 
                gfs2_assert_withdraw(sdp, !pull);
633
 
 
634
 
        sdp->sd_log_idle = (tail == sdp->sd_log_flush_head);
635
 
        gfs2_log_incr_head(sdp);
636
596
}
637
597
 
638
598
/**
678
638
 
679
639
        gfs2_ordered_write(sdp);
680
640
        lops_before_commit(sdp);
 
641
        gfs2_log_flush_bio(sdp, WRITE);
681
642
 
682
643
        if (sdp->sd_log_head != sdp->sd_log_flush_head) {
683
 
                log_write_header(sdp, 0, 0);
 
644
                log_write_header(sdp, 0);
684
645
        } else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle){
685
 
                gfs2_log_lock(sdp);
686
646
                atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */
687
647
                trace_gfs2_log_blocks(sdp, -1);
688
 
                gfs2_log_unlock(sdp);
689
 
                log_write_header(sdp, 0, PULL);
 
648
                log_write_header(sdp, 0);
690
649
        }
691
650
        lops_after_commit(sdp, ai);
692
651
 
735
694
        gfs2_log_unlock(sdp);
736
695
}
737
696
 
738
 
static void buf_lo_incore_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
739
 
{
740
 
        struct list_head *head = &tr->tr_list_buf;
741
 
        struct gfs2_bufdata *bd;
742
 
 
743
 
        gfs2_log_lock(sdp);
744
 
        while (!list_empty(head)) {
745
 
                bd = list_entry(head->next, struct gfs2_bufdata, bd_list_tr);
746
 
                list_del_init(&bd->bd_list_tr);
747
 
                tr->tr_num_buf--;
748
 
        }
749
 
        gfs2_log_unlock(sdp);
750
 
        gfs2_assert_warn(sdp, !tr->tr_num_buf);
751
 
}
752
 
 
753
697
/**
754
698
 * gfs2_log_commit - Commit a transaction to the log
755
699
 * @sdp: the filesystem
768
712
void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
769
713
{
770
714
        log_refund(sdp, tr);
771
 
        buf_lo_incore_commit(sdp, tr);
772
 
 
773
715
        up_read(&sdp->sd_log_flush_lock);
774
716
 
775
717
        if (atomic_read(&sdp->sd_log_pinned) > atomic_read(&sdp->sd_log_thresh1) ||
798
740
        sdp->sd_log_flush_head = sdp->sd_log_head;
799
741
        sdp->sd_log_flush_wrapped = 0;
800
742
 
801
 
        log_write_header(sdp, GFS2_LOG_HEAD_UNMOUNT,
802
 
                         (sdp->sd_log_tail == current_tail(sdp)) ? 0 : PULL);
 
743
        log_write_header(sdp, GFS2_LOG_HEAD_UNMOUNT);
803
744
 
804
745
        gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_blks_free) == sdp->sd_jdesc->jd_blocks);
805
746
        gfs2_assert_warn(sdp, sdp->sd_log_head == sdp->sd_log_tail);
854
795
        struct gfs2_sbd *sdp = data;
855
796
        unsigned long t = 1;
856
797
        DEFINE_WAIT(wait);
857
 
        unsigned preflush;
858
798
 
859
799
        while (!kthread_should_stop()) {
860
800
 
861
 
                preflush = atomic_read(&sdp->sd_log_pinned);
862
801
                if (gfs2_jrnl_flush_reqd(sdp) || t == 0) {
863
802
                        gfs2_ail1_empty(sdp);
864
803
                        gfs2_log_flush(sdp, NULL);