LP2PFS: Um Cliente VFS Linux Para O Sistema LP2P
Total Page:16
File Type:pdf, Size:1020Kb
LP2PFS: Um Cliente VFS Linux para o Sistema LP2P por Daniel Stefani Marcon UNIVERSIDADE DO VALE DO RIO DOS SINOS DANIEL STEFANI MARCON LP2PFS: Um Cliente VFS Linux para o Sistema LP2P Monografia apresentada como requisito parcial para a obtenção do grau de Bacharel em Ciência da Computação Prof. Dr. Rafael Bohrer Ávila Orientador São Leopoldo, Dezembro de 2010 “Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that’s creativity. — Charles Mingus DEDICATÓRIA Dedico este trabalho a minha dinda-mãe Darcila, que sempre me apoiou e me ajudou em todos os momentos da minha vida. AGRADECIMENTOS Agradeço, em primeiro lugar, a Deus, por ter me proporcionado finalizar este trabalho. Agradeço a minha dinda-mãe Darcila e ao meu dindo Fausto pela ajuda em todos os momentos durante esse trabalho, que me apoiaram durante toda a minha vida para mim chegar até aqui. Agradeço ao meu orientador Rafael, por toda a orientação durante o trabalho, pelos conselhos sobre a melhor forma de implementar o sistema de arquivos, sobre o que escrever e como apresentar o projeto nessa monografia e pelas revisões desse texto. Agradeço a todos os meus amigos que me ajudaram durante esse trabalho, direta ou indiretamente. SUMÁRIO LISTA DE ABREVIATURAS E SIGLAS . .7 LISTA DE FIGURAS . .9 LISTA DE LISTAGENS . 11 LISTA DE TABELAS . 12 RESUMO . 13 ABSTRACT . 14 1 INTRODUÇÃO . 15 2 REFERENCIAL TEÓRICO . 19 2.1 Sistemas Centralizados ............................ 19 2.1.1 Network File System - NFS ........................ 19 2.1.2 Samba ................................... 22 2.2 Sistemas Distribuídos ............................. 24 2.2.1 Coda .................................... 24 2.2.2 Serverless Network File System - xFS ................... 26 2.3 Sistemas Peer-to-Peer ............................ 28 2.3.1 Gnutella .................................. 29 2.3.2 Freenet ................................... 31 2.3.3 Ivy ..................................... 33 2.3.4 BitTorrent ................................. 35 2.4 Síntese .................................... 37 3 LOCAL PEER-TO-PEER PROTOCOL . 40 3.1 Arquitetura .................................. 41 3.2 Mensagens de Comunicação Interna ..................... 44 3.3 Módulos Externos .............................. 46 4 LP2P FILE SYSTEM . 48 4.1 Implementação ................................ 48 4.1.1 Virtual File System ............................. 49 4.1.1.1 Mapeamento dos Metadados dos Arquivos ............... 55 4.1.2 Page Cache ................................ 55 4.1.2.1 Mapeamento dos Dados dos Arquivos ................. 57 4.2 Otimizações .................................. 58 4.3 Comunicação com o LP2P .......................... 60 4.4 Notificação de Eventos ............................ 61 4.5 Arquivo no Sistema Procfs .......................... 62 4.6 Opções de Montagem ............................ 63 5 VALIDAÇÃO E RESULTADOS EXPERIMENTAIS . 64 5.1 Versões do Kernel .............................. 64 5.2 Disponibilização dos Arquivos ........................ 65 5.3 Testes no Sistema LP2P ........................... 66 6 CONCLUSÃO . 73 REFERÊNCIAS . 75 LISTA DE ABREVIATURAS E SIGLAS API Application Programming Interface CA-NFS Congestion Aware Network File System CIFS Common Internet File System CHK Content-hash Key DNS Domain Name System DNS-SD Domain Name System Based Service Discovery FTP File Transfer Protocol GCC GNU Compiler Collection GNU GNU’s Not Unix! HTTP Hypertext Transfer Protocol KSK Keyword-signed Key LAN Local Area Network LFS Log-structured File Systems LRU Least Recently Used mDNS Multicast Domain Name System NFS Network File System P2P Peer-to-Peer pNFS Parallel Network File System POSIX Portable Operating System Interface RAID Redundant Arrays of Inexpensive Disks RPC Remote Procedure Call RTT Round-Trip Time SHA Secure Hash Algorithm SMB Server Message Block SSK Signed-subspace Key VFS Virtual File System TTL Time-to-live xFS Serverless Network File System LISTA DE FIGURAS Figura 1.1: Estrutura do sistema LP2P ...................... 17 Figura 2.1: Estado da página em memória com escrita assíncrona ........ 21 Figura 2.2: Estrutura de um cliente Coda ..................... 25 Figura 2.3: Leitura de um bloco no sistema xFS (fonte: Anderson et al. (1996)) 27 Figura 2.4: Estrutura da rede Gnutella ...................... 29 Figura 2.5: Rede de sobreposição Gnutella com os nodos mal distribuídos .... 30 Figura 2.6: Procura de um arquivo na rede Freenet ................ 33 Figura 2.7: Estrutura do sistema Ivy ........................ 34 Figura 3.1: Funcionamento do LP2P ....................... 41 Figura 3.2: Arquitetura do sistema LP2P ..................... 42 Figura 3.3: Comunicação interna do sistema LP2P ................ 44 Figura 3.4: Estrutura da mensagem LP2P ..................... 44 Figura 3.5: Formato da mensagem llist ...................... 45 Figura 3.6: Formato da mensagem lsendl ..................... 45 Figura 3.7: Formato da mensagem lgetu ..................... 46 Figura 3.8: Formato da mensagem lsendu ..................... 46 Figura 3.9: Formato da mensagem lget ...................... 46 Figura 3.10: Formato da mensagem lsendf ..................... 47 Figura 4.1: A camada de abstração do VFS .................... 49 Figura 4.2: Relações entre os objetos do VFS (fonte: Mauerer (2008)) ..... 54 Figura 4.3: Relação entre as estruturas do VFS e do Page Cache (fonte: Mauerer (2008)) ................................. 56 Figura 4.4: Exemplo de uma árvore radix (fonte: Mauerer (2008)) ........ 58 Figura 4.5: Estrutura com alinhamento de bytes (fonte: Mauerer (2008)) .... 60 Figura 4.6: Montagem do sistema LP2PFS .................... 60 Figura 4.7: Leitura do conteúdo de um arquivo .................. 61 Figura 5.1: Compartilhamento de pacotes Debian ................. 65 Figura 5.2: Vazão de dados usando TCP ..................... 66 Figura 5.3: Latência de comunicação usando TCP ................ 67 Figura 5.4: Vazão individual de cada peer para arquivos de 1 MB ........ 68 Figura 5.5: Vazão individual de cada peer para arquivos de 8 MB ........ 69 Figura 5.6: Vazão individual de cada peer para arquivos de 16 MB ........ 70 Figura 5.7: Vazão agregada do sistema ...................... 71 LISTA DE LISTAGENS Listagem 4.1: Estrutura super_block ....................... 49 Listagem 4.2: Estrutura inode ........................... 50 Listagem 4.3: Estrutura dentry .......................... 51 Listagem 4.4: Estrutura file ........................... 53 Listagem 4.5: Estrutura file_system_type ................... 54 Listagem 4.6: Estrutura address_space ..................... 56 Listagem 4.7: Funções de leitura de páginas .................... 57 Listagem 4.8: Função __builtin_expect .................... 59 Listagem 4.9: Macros likely e unlikely .................... 59 LISTA DE TABELAS Tabela 2.1: Síntese das características dos sistemas estudados .......... 39 Tabela 5.1: Teste do sistema com arquivos de 1 MB ............... 68 Tabela 5.2: Teste do sistema com arquivos de 8 MB ............... 69 Tabela 5.3: Teste do sistema com arquivos de 16 MB ............... 70 Tabela 5.4: Vazão agregada do sistema ...................... 71 RESUMO Sistemas de distribuição de arquivos em rede tem como principal objetivo per- mitir o compartilhamento de dados entre os seus usuários, provendo uma ou mais das seguintes características: transparência de localização, replicação de arquivos, tolerância a falhas, eficiência, segurança e consistência. Nesse contexto, no âm- bito do Programa Interdisciplinar de Pós-Graduação em Computação Aplicada da Unisinos (PIPCA), surgiu a proposta de desenvolver um sistema peer-to-peer para redes locais, o Local Peer-to-Peer Protocol (LP2P), possibilitando a rápida troca de arquivos entre os componentes da rede. Esse sistema, através de seus módulos externos, disponibiliza funções de descoberta de serviços e mecanismos de segurança e otimização para a transferência de arquivos entre os peers da rede. No entanto, é necessário o desenvolvimento de uma interface robusta e de fácil utilização para o sistema. Desse modo, nesse projeto, foi implementado um módulo para o kernel do Linux, que atua como um sistema de arquivos, denominado LP2PFS. Esse módulo permite disponibilizar os arquivos presentes no sistema LP2P, atuando como a sua interface com o usuário. O LP2PFS foi desenvolvido com base na camada de abs- tração do kernel para sistemas de arquivos, o Virtual File System (VFS), utilizando o subsistema de Page Cache para o armazenamento dos dados na memória. O sis- tema de arquivos apresenta as funcionalidades de notificação de eventos ocorridos no sistema às aplicações, através da interface fsnotify, além de possuir um arquivo virtual no sistema Procfs, com dados da sua montagem e dos arquivos presentes no sistema. O módulo LP2PFS obteve êxito em todos os testes executados. A sua implementação é compatível com diversas versões do kernel do Linux e a disponi- bilização dos arquivos presentes no sistema LP2P foi alcançada, sendo comprovada pela verificação da integridade dos dados desses arquivos através do algoritmo MD5. Por fim, foram realizados testes de desempenho do sistema de arquivos em conjunto com o sistema LP2P, através dos quais foi comprovado o desempenho e a eficiência do módulo implementado. Palavras-chave: Sistema de arquivos. peer-to-peer. LP2P. LP2PFS: A VFS Linux Client for the LP2P System ABSTRACT Network file distribution systems aim to allow data sharing among users, pro- viding some of the following features: location transparency, file